-3

These days, I see people always extolling the benefits of using Static Site Generators (SSG) for building static sites. Why would I not just write the HTML/CSS myself? What's the advantage of using an SSG, such as Gatsby?

4
  • 2
    Say you're trying to create a blog. You write a webpage with one article. Then another. Then a frontpage with a list of items. Then you want to change the theme. You could edit all of the pages. That's doable for only three, but quickly gets of of hand. So you want a content management system (CMS) that lets you separate themes/templates from the actual content. You can't do that just with JS on the frontend (unless you're creating a SPA, but that has some problems of its own). A static site generator is simple, secure, and scalable because you just serve HTML files, no databases needed.
    – amon
    Commented Nov 5, 2023 at 22:45
  • 1
    The premise of this question doesn't make sense to me. The question is phrased as if plain JavaScript is a substitute for a static site generator. I mean, you could get it to work, but that's not really that use case for JavaScript. Commented Nov 6, 2023 at 14:45
  • 1
    @Greg Burghardt My apologoies, I misspoke; I should rephrase: I meant a site built manually with HTML/CSS. Commented Nov 6, 2023 at 19:23
  • @IntelliData: any reason why you changed the content of your question without editing the title, so both don't match any more?
    – Doc Brown
    Commented Nov 7, 2023 at 6:59

2 Answers 2

3

I'm using Gatsby for my own blog. Here are some benefits I can share based on my experience.

Usually, people use SSG writing their blogs. You have a template or skeleton as the layout for all of blogs, and you have something called Content Managing System to manage your articles.

You can write your template however you want. You can build your own framework with pure HTML/CSS/JS. Or you can utilize the existing frameworks to skip the unnecessary stuff. GatsbyJS or Hugo allows you to write code if you have experience whereas Wordpress and Wix allows you to design your blog with UI interactions.

Next is the content. Content can be composed in their own way. There are sites that let you design your content with UI just like Word. Wordpress and Wix intergrate their own CMS so that non-experience can develop their whole blog fully. Or, you can go with Markdown (like you type in this post) and manage your own content. you can do it with Gatsby. It also integrates very well with CMS.

The most important part is how you link your layout to your content. Wordpress and Wix will do it for you. You pick a theme, you write your own content and you publish it. GatsbyJS provides their own official plugins and gives you the full responsibility. How you want to link, how you want to navigate, what you put in the metadata, etc.In a simpler way, you can generate an HTML page based on your markdown files. But before generating the HTML page, GatsbyJS will wrap it with the layout you provide to generate a full page (layout + content).

If that is your intention, then yes, you should use SSG. If your intention is just a landing page, an about page or pages are not relevant to each other, you can just use HTML/CSS/JS, no need for the hassle.

0

In short, you use such frameworks or tools when they give you an advantage in time or cost over not using them. What these advantages are and whether they are applicable to your specific requirements depends on the specific tools and is beyond the scope of this site. Check the documentation of the various options, try out some examples, and come to your own conclusion.

5
  • Well, I've tried searching google and I haven't really found any good answer to my question. The only other way for me to find out is building my portfolio site with vanilla js, and then again with gatsby etc. I think that instead of trying it every single possible way, it makes more sense to ask, don't you think? Commented Nov 5, 2023 at 21:51
  • The question itself makes sense, but (IMHO) isn't on-topic for this site as it is likely to elicit opinion statements and not objective answers. I'm afraid I also can't point you at a good place for asking such questions, sorry. Commented Nov 6, 2023 at 5:31
  • 1
    "I think that instead of trying it every single possible way, it makes more sense to ask" - there are case where it does not make more sense. The answer whether a specific SSG brings you benefits over implementing your requirements in vanilla JS depends mainly on your requirements, how well those are supported by the SSG, your own knowledge of JS and your knowledge of the SSG. You could try to write this all into a question (maybe in a question in a forum for the specific SSG, not here), but the only way for really gettin a useful answer will probably be to try it out.
    – Doc Brown
    Commented Nov 6, 2023 at 6:55
  • 1
    @Doc Brown I get what you're trying to say, and I appreciate your help. My question is not necessarily about any specific SSG, but about SSGs in general - why would something like that be needed. Commented Nov 6, 2023 at 7:01
  • 1
    The comment by @amon deserves to be an answer, as it cites a common use case where SSG makes sense. Commented Nov 6, 2023 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.