2 answers
Start by doing real projects for real people, even if you're doing them for free or cheap at first - that's how you get work samples that actually matter. Build a few solid pieces you can show (whether that's websites, designs, writing samples, whatever your field is) and document them well with before/after shots or case studies. Once you have a handful of decent work, make it easy for potential clients to see what you've done and reach out - a simple portfolio site or GitHub repo beats a fancy one with nothing in it. The key is getting that first real project done, even if it takes longer and pays less, because employers can tell the difference between theoretical knowledge and something you actually built.
The thing that actually sets a portfolio apart is depth over breadth. People hiring want to see that you solved real problems, not just that you did a bunch of things. Pick 3-5 projects maximum and for each one, document what the challenge was, what you tried, what worked and what didn't. Show your thinking, not just the final result. If you're building from scratch, take on a project for someone you know - a friend's small business website, a local nonprofit's social media overhaul, whatever fits your field - and treat it like a real client project with deadlines and revisions.
The other stuff people mentioned about contributing to open source or doing small gigs is solid, but make sure whatever you put in your portfolio tells a story. Employers see right through a collection of random tasks. They want to know you can handle complexity and iterate when something doesn't work the first time. That's the difference between a portfolio that gets ignored and one that gets you meetings.
Your answer
Log into answer.