I got this question from a listener the other day. Fair question, I’d say. The word “Static” in “Static Site Generator” is at-odds with the word “Dynamic.” It seems to imply that the website created with a Static Site Generator (SSG) is locked in stone, only to be changed when it is run again some future date. That’s a somewhat unfortunate implication, if entirely understandable.
“Static Sites,” in actuality, can be as dynamic as any other side because of one¹ thing baked right in an available to any website: JavaScript. JavaScript can, say, hit an API and update the otherwise statically generated markup of a page. Just think. JavaScript. APIs. Markup… J… A… M… Jamstack!
Part of the trick to understanding this Jamstack world (aka Static Sites that do Dynamic Things) is just looking at what Netlify offers. Netlify literally only offers static hosting. No server-side languages (think Ruby, PHP, or Python) serving up individual pages on Netlify. So SSGs and Netlify go hand in hand. But let’s go through it as a list:
- Netlify runs your build process for you. Which very likely includes a SSG. The point of which is largely that you keep your built site files out of your version control system, which would otherwise be a wasteful mess.
- Netlify processes your forms. No need to run an always-on server just for this dynamic feature.
- Netlify offers authentication. That’s right reader, auth is a first-class citzen of the platform.
- Netlify runs your server side code in the form of cloud functions. Static hosting doesn’t mean you can’t do server side things. It means you do server side things with modern, cheap, secure, focused, fast, powerful cloud functions.
- Netlify can build pages on-demand. Meaning you don’t have to pre-build all your pages if you don’t want to.
That’s just some of the feature set. Here’s a fun blog post from a little while ago with some of the staff’s favorite features, many of which aren’t in the list above. Jamstack is starting to literally mean that indeed dynamic things are happening to a static site.
I hope that answers the question for this particular reader and anyone else with the same confusion. SSGs can produce entirely static websites with zero dynamic data and that offer no special logged-in experience. But they can also be every bit as dynamic as any other site, just built from a more solid, static foundation.
- Well, let’s say two things. Dynamic things can be done via edge handlers as well, without the need for client-side JavaScript.
This is a great post, but with such a focus on how static sites can also be dynamic – I think you forgot to explain what makes them static in the first place. What is the difference between static and non-static.
You’re right. It’s a misconception. However, SSGs are great for websites that do not need to update all the time. Otherwise, the experience might be worse, and not all SSGs provide a preview, which is helpful for contributors.
I’m a big fan of SSG. I use them all the time, but there are some caveats. Besides, many essential features such as search, forms, and comments require third-party integration and additional code.
I think the misconceptions you mentioned might be related to that. Compared to WordPress and other solutions, SSG may appear as barebone. I prefer this approach, but not everybody has the necessary skills to maintain it, even if Netlify is amazing.
Oh boy. This “static” and JAM reminds me of the age before PHP. When all we had was HTML and little JS. People forgot why the Dynamic part was invented in first place. This is like in fashion, the 90’s are the new 2021’s.
Good luck, kiddos.
This actually confuses me more, if that is the case, what is the difference between a normal SPA and a static site? Why does everyone indicate that they are different?