Is it better for full stack web developers to specialize or generalize as they grow their careers over time?
Having a working knowledge of the full stack, generalists are flexible and versatile across the stack and across languages and frameworks, but they may lack deep knowledge in any particular area and may not be able to handle the more challenging requirements in a given area.
Front-end and back-end specialists have deep knowledge in their area, but do they paint themselves into a corner if their chosen specialization (e.g. framework, stack, etc.) falls out of fashion?
How then to develop deep knowledge in a specialized area as well as adaptability and versatility as one charts a career path?
Generalize in technologies, but specialize in a market or two (e.g. health care, finance, real estate). Become a subject matter expert. As a technology-agnostic person, you'll be much more valuable with subject knowledge than technology knowledge, IMO. Technologies come and go, so if you specialize in one area, you'll end up painting yourself into a corner and when your job dries up, it will be that much harder to find employment elsewhere. The other side of this is that if you do specialize in a niche technology, you may become very sought after as one of only a handful of people who know it. I've seen this happen with off-technologies, and those people get paid big money for their expertise. It all depends on whether you want to be marketable to a wider range of employers or not.
I personally hate specialising, but let's face it, you are more likely to find a job at a big company if you're specialised.
It depends on what size of projects you are working on, how much time you put into it and of course where your interests are.
I don't think that this question is deserving of being answered by a binary choice, because like most things it will depend on the person. But I would like to answer your final question; you simply need practice.
By creating projects and releasing them into the wild, you will develop skills that will help to influence projects down the road. I started my open source journey back in 2013, with writing a basic tasks list for Grunt. A few months passed and gulp came along and I was able to apply my skills of knowing how to publish node modules to writing a few gulp plugins. Fast forward a year or so and I'm writing a CSS minifier based on PostCSS, whilst my current work is involved with parsing CSS property value pairs at a very deep level.
Now, a lot of this work is focused on CSS, and written in JavaScript. But I've learned how to write parsers, had a ton of experience with writing tests, fixing bugs and developing my technical skills. And I achieved this because I was interested in doing these things. The more opportunities that you use to further your skill set, the more adaptable you will become, so long as you apply your existing knowledge to new concepts and ideas.
Where possible I will also try to help other people with problems; I do this in issues most of the time, but I lurk in lots of online chats and answer when I can. Trying to solve other people's problems is a great way to apply what you know in a different area; maybe you have not run into that particular problem before, so you force yourself to think how you would solve it, and then you can answer their question. This will help you develop both your technical and soft skills, and soft skills are essential for any career.