@
deanhills
That is a nice topic. I know some things owing to my wide grazings through greener pastures. hahaha
What are SSGs ?
In case of HTML sites, you write each page with code and content and ensure that the design (links, menu, look etc) is uniform. So for every new page, you need to copy-paste a lot of boilerplate codes. Now think of when you change something in design and need to update the boilerplate code on hundreds upon hundreds of pages.
In case of SSGs, the design part is separated in common files and you do it once. So basically SSGs use templating.
##Very important ##
The static site generator then uses the template definition files and the topic content files and makes all the static pages during deployment time. So when you add new page, you only generate those static pages by SSG but
everytime you do some change in design, you need to recreate all the static pages by the generator. Though you do it when you want and not when a viewer requests, as in case of dynamic sites. But this means you have to ensure your update is complete before taking it live, or there might be inconsistencies from user perspective.
When browser requests a page from an SSG site, it gets a couple of static files very fast ( no server side rendering) and renders them on screen.
So in a way, SSGs are like an automated system to copy paste all your boilerplate coomon HTML codes to all of your static pages.
Static Site Generators (SSGs) are a compromise between handcoded HTML CSS sites and CMS or content management systems in an effort to get the benefits from both worlds.
What benefits you might ask ?
Well, from HTML coded static site world,
(1)
SPEED > html sites don't need access time rendering or compiling. They are static. So they can be distributed to servers or cdn edge servers(called caching*1*check note below) worldwide during deployment and that radically reduces TTFB or time to first byte. When a site is snappy in loading, it contributes greatly in user satisfaction and retention (search for statistics on how load time contributes to site success. It is more important than you might think).
Check this link for a test.
https://gettingthingstech.com/hugo-vs.-w...-its-dust/
*1* Dynamic sites can and often do caching too. In theory they are meant to generate each page when requested by the browser. But to enhance performance and reduce load, they cache many of the pages that change less often and thus configured to cache. When something changes, they just purge the cache and load the new version in cache.
(2)
Need less Server resources > Html sites also require much less in terms or resource and so a similar spec server would serve many more simultaneous users when used to host html sites.
(3)
Improved security > Highly improved security. Reduced surface of attack due to it being less complex and easier to maintain.
from CMS world,
(4)
Easier management of page design and improved readabilty of the topic content files ( debatable ?).
I guess I won't have to explain why every site can not be static. You can not do it with sites showing news or say stock data or anything that involves fast changes and or requires user interactions for obvious reasons. Can Twitter or Facebook be static sites. LMFAO.
Dynamic sites were developed to handle these very things. To establish an efficient way to incorporate fast change in site content.
Now here are the
problems with SSGs.
1)
Steep learning curve > You need to be very knowledgeable. A web dev or more. Why ?
For example, these SSGs don't have established ways to check input before rendering. You can not enter whatever you want wherever you want on an wordpress site. It has fields with checks in place.
You are responsible for everything you write down and you are the one who is making the designs and taking decisions in every case. So you need to know what you are doing.
2)
Problem handling fast change and user interaction > Login , content restriction, collaboration, dynamic update are not things handled easily or at all by these sites.
3)
Scaling > You can at most handle couple of hundred pages. For sites with thousands of pages, the whole process will just become too much.
Therefore,
If you want to do your small static sites with these, then great !!
I would choose something that uses Go (HUGO) or Javascript(NextJs or Gatsby). Also you might wanna start looking at Netlify (netlify.com) free tier and their docs and also resources at jamstac.org
staticgen.com can be used to find more on SSGs.
THANKS
Good Day !!