There are so many ways to learn how to code, and as the industry gets bigger and new technologies are developed it can become complicated. Here are some of the methods that I have personally seen work with my friends and colleagues.
There are many choices to make and different things you can study to become a successful developer. The main aim of this post is to help you understand where to start and perhaps some of the best places to get started.
The first thing I would recommend is your mindset going into this. No matter why you're looking to learn how to code, approach it as you would learning any new hobby. By doing this you won't put too much pressure on yourself to learn everything there is and can listen to your own intuition and follow what interests you. If you're driven by enjoyment and curiosity, you'll learn much more than trying to tick off lists of things you think you should know.
Accept that there will always be things you don't know or understand. No matter how much experience or how good any programmer is, there will always be people new tech they've never heard of or have never used.
The important thing is that you get an understanding of some fundamental concepts in programming, and then get good at fixing and learning things when something goes wrong and get an intuition of where to go and what to do when you don't understand.
After you get the basics down, try and make things. Find a tutorial series on Youtube that interests you, think of something small you want to make, or find a course that will teach you something you want to know with a project based approach.
Figure out how you like to learn. Some people will prefer blog tutorial series, some people (like me) prefer video and use YouTube and course platforms such as Udemy or Frontend Masters.
With all that being said about how I recommend beginners approach learning how to code, here's a more practical checklist I'd recommend.
If you know what language you want to learn go for it, after you learn the fundamentals of one programming language, the concepts carry over very well, although each language has its own opinions, quirks and style.
Codecademy is the platform I first used to learn how to code and always recommend to somebody with no experience. You can start by following a YouTube series or blog series but I think Codecademy is good because you're always writing code and getting those 'aha' moments where you solve problems and actually write code the entire way.
The free 'getting started with' courses are exactly what you need and I wouldn't worry about upgrading to Codecademy Pro unless you want a full 'bootcamp' like experience and are really looking for a career change. Just go through one exercise at a time until you finish it or get bored.
If you're looking to build websites, I'd also take a look at the Codecademy HTML and CSS courses.They're not strictly programming languages, but they are the building blocks of the web, HTML define the content of a website with tags (all the text, images, links etc) and CSS defines the styling (where should all the content go on the screen and how should it position itself based on different screen sizes).
Also, I'd recommend you move off the Codecademy platform (unless you decide to go with Codecademy Pro). It's great for learning how code works and the concepts, but if you want to build things for yourself, or get a job building things you'll need to understand how to build things outside of the Codecademy interface.
I think this would be a good and sustainable way for somebody to learn how to code as a hobby. From this point you should know enough to decide if you want to really put in work to become a professional software developer, or enough to be able to tackle the project you've always wanted to build.