It depends on what kind of guitar player you want to be. If you want to be an adaptable guitar player who can play multiple genres and talk with other musicians at a technical level then there are many YouTube channels and websites devoted to learning guitar and music theory that will get you to a decent standard without needing a teacher. But if you really want to progress past an intermediate level then you’ll need a teacher at some point for sure.
If however, you’re only interested in one genre of music and you’re not interested in understanding theory, then you may be best off learning by ear. Once you have a basic grasp of how to make noises come from your guitar, listen to your favorite band and try and copy what you hear. Then once you feel like you’re playing the same thing, record yourself and be objective. If your favorite band has a super technical guitarist, then you should probably revisit this idea once you’ve spent a lot of time on YouTube guitar learning channels. This ear route of learning will develop your listening ability well, which is ultimately the most important skill, however, you may run into problems of insecurity due to not feeling like you really understand what you’re playing.