Static site generator vs creating files manually

Hello, can someone explain what's the purpose of a static site generator? How does it differ from the normal way of creating an HTML file?
9 Replies
Jochem
Jochem2mo ago
static site generators use content that can be dynamic at the time of generating you can have 500 blog posts in a folder in .md format, then use a static site generator to turn that into a blog with links and an archive and recent posts
Faker
FakerOP2mo ago
hmm yeah I see but what's the difference between a static site generator and a content management system? Both seem to generate code dynamically ?
Jochem
Jochem2mo ago
a static site generator does it once on the developer's machine, a CMS does it on the server for each user request
Faker
FakerOP2mo ago
yep I see, will read a bit more and come back, thanks !
13eck
13eck2mo ago
A SSG generates static content. A CMS manages content. What the CMS does after content is changed depends on what you've told it to do. It could be hooked up to a SSG and once you hit save it generates new static content. Or it could be hooked up to a SSR (server-side renderer) where the content is generated on-demand when a request for it comes in. As to your initial question: a SSG takes content in a format that's easier to author (like markdown) and generates HTML. Lots of HTML. So much HTML your fingers would fall off typing that much :p Markdown doesn't require opening and closing tags, so it's not as time consuming to author. And the SSG takes care of all the repetitive stuff, like inserting the "pre-roll" HTML like the head tag, any meta tags, shared CSS/JS tags, etc. You write the pre-roll and post-roll HTML once and the SSG stitches it all together. That way if something changes in, say, the footer of the site, you don't need to update it in ever. Single. Page. That. Exists. :phew: that's exhausting! You just change the code in the footer template and re-generate the entire site and BOOM! Updated across the board. SSGs allow you to work smarter, not harder.
Faker
FakerOP2mo ago
oh ok I see, that's definitely something I need to check, thanks !
ἔρως
ἔρως2mo ago
basically, a static site generator does what you would do manually for all html files, but automatically imagine having to then update a link in the header of over 500 pages ... yikes!
b1mind
b1mind2mo ago
You can have a CMS that does SSG just saying The two things are not the same to compare
ἔρως
ἔρως2mo ago
yup, that too there's the thingy for astro, for example eleventy or whatever it is

Did you find this page helpful?