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
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
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 ?
a static site generator does it once on the developer's machine, a CMS does it on the server for each user request
yep I see, will read a bit more and come back, thanks !
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.
oh ok I see, that's definitely something I need to check, thanks !
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!
You can have a CMS that does SSG just saying
The two things are not the same to compare
yup, that too
there's the thingy for astro, for example
eleventy or whatever it is