Is there a way to store common HTML code and then reference it in the code?

I have a navbar that I would like to not have to update on every webpage every time I change the URL of a page.

Yep, consider using templating engines to do this. I personally think the simplest one for beginners is EJS. There are plenty of tutorials on it on the web.