Skip to main content

From Gatsby to Eleventy

5 mins 📖 📖 📖 

ssg

In this post I'll compare my experience building my personal blogging site (the one you're on now) with two static site generators (SSGs) - Gatsby and Eleventy.

The first version of my site was rolled out with Bootstrap CSS and no framework, the second and third used SCSS and again no framework. The fourth version was built with a popular static site generator (SSG) called Gatsby. This SSG uses React and GraphQL. My learning curve from using no framework to using Gatsby was not huge though, as I use React and GraphQL at work.

The fifth, and at the time of publishing this post, current, version of this site uses a static site generator called Eleventy. I was a bit daunted about using this SSG, because the tools I was used to working with all day weren't baked in. This meant no default React, or GraphQL. This SSG would be a new paradigm for me to learn from scratch. I'd have to pick a templating language I had never used before, and learn how Eleventy manages data. Even so, there were a number of reasons I wanted to move from Gatsby to Eleventy.

Firstly, I'll summarise the reasons that I decided to use Gatsby in the first place. It lets people write React, takes care of a lot of performance concerns for you, and has a lot of good starter templates. So, it's excellent for getting started quickly, getting a reasonably good site created, and offers a good developer experience. This was a big pull for me, in addition to all the hype it was creating a few years ago, and the fact I could already use its baked-in tools. Also, the fact I could have my very own, nice and shiny single page app (SPA) was a plus for me, at the time.

Gatsby sounds really good, so why did I move to Eleventy? This is a question I've put a lot of thought in to. First, I want to explain that I didn't add any new features to the site between the Gatsby and Eleventy versions. The only thing that changed is that now, all the learn posts have their own page, instead of existing on one page.

Benefits Gained

  • As my Eleventy site outputs a non-SPA, I didn't need to check or ensure that it is server-rendered, is able to be crawled by search engines to allow good search engine optimisation (SEO), or works without JavaScript. Non-SPAs do all of this by default.
  • A number of Gatsby plugins stopped some of the functionality on my site working. For example, Gatsby's progressive web app plugin caused my server-side rendering to stop working.
  • My site is a personal blog site that does not have thousands of users or masses of data. So, I don't need to make sure I'm saving on bandwidth or server resources. If I did need that, I would consider creating a SPA, as they tend to request fewer server resources across page views, compared to non-SPAs.
  • I don't need to force users to download large chunks of React library in their browsers. Gatsby by default forces this, and requires a plugin to ensure that React is only used on the server.
  • I didn't need to bother code-splitting any React components to ensure users aren't downloading my whole site on initial page load.
  • I was able to gain more control over performance optimisations such as image rendering. When I first released my Gatsby site, I used their image plugin but ended up disliking several things about it, such as styling inflexibility, and inability to use the <picture> element.
  • I know enough about web development that I can write performant code on my own. Therefore, I can do without plugins that enhance performance, but don't make it clear how they do so. Also, I prefer using my own skills to create things wherever possible, as it teaches me how things really work.
  • I could pick and choose what JavaScript is necessary in the client (browser), thereby limiting the size of the JavaScript a user needs to download. The only JavaScript my site needs on the client-side is for the dark mode toggle, the blog search input, a tiny (and privacy-first) analytics tool, and some linked data (JSON-LD) for SEO.
  • By writing lower-level template code (Nunjucks vs JSX), I felt like I had more control over the generated code, which allowed me to output better and more consistent HTML.
  • Gatsby has GraphQL baked in. For a lot of use cases, especially a personal blog site, GraphQL is overpowered and can be a large learning curve for some.

Challenges Faced

  • Eleventy is newer and maintained by less people than Gatsby. Therefore, I felt that Eleventy is a bit less feature-rich and has less documentation. Although honestly, this isn't a huge deal. Firstly, I found Eleventy simpler to use (less abstract), and found the documentation covers all the most important aspects of the SSG. Secondly, almost any time I needed extra help or information, I found it in the form of excellent blog posts or example repositories created by other web developers.
  • One of the very few issues I couldn't find help with was the sharing of one type of data (blog post excerpts) across my Eleventy-powered site. Gatsby, along with React, makes it easy to see what data is being shared and how. Eleventy has a fantastic data-sharing API (in my case the data sharing was orchestrated between Nunjucks and the Eleventy config file). However, I found it to be quite abstracted and struggled a lot trying to get my blog post excerpt data to be easily shared across pages. In the end, I created a workaround for this, but this workaround is quite hacky. I plan to write about it in a separate post.
  • I had to learn how to use the Nunjucks templating language. This is only a small nitpick, as the learning curve was in no way steep.

Concluding Thoughts

Using Gatsby has taught me a lot about single page apps, and that's important! Sometimes using it was frustrating, and a few things broke without me realising why or even when, but these experiences can be good lessons. Also, I am employed to work on a large SPA, and probably will continue to work on SPAs professionally for years to come, so any experience working with them is good!

I believe it is a good idea to use the least-powerful technology possible for any given task. Building with Eleventy made this possible for me. I find React and GraphQL nice to use, and I was daunted at the thought of not being able to use JSX. But, using simpler and lower-level tools such as Nunjucks made me feel more confident about my site's output (robust HTML and the least JavaScript possible), and I enjoyed the experience much more than I thought I would.

Please don't take what I've written here as a reason not to choose Gatsby over Eleventy. I chose to re-write my site in Eleventy for several reasons. I have the knowledge to build in performance and accessibility myself, I realised I didn't need an SPA for my use case, and I wanted to use simpler, less powerful developer tools. I think developers should use the tools that suit them best. There is only one thing I want to encourage you to do: no matter what tools you use, please pay attention to your site or app's final output! It's never a good idea to make users pay for your technology choices.

Buy me a coffee ❤️

132 Responses

 
Frederic MarxSiddharthLewis Nyman 🇵🇹Emily 🍄Philip Saa 🇩🇪 #AutumnTom Hazledinematteo grilliflaki + 96 more

13 Reposts

Frederic MarxTom HazledineflakiRamón HuidobroEleventyZach LeathermanAndy BellKale Wishboneman 🦃🥬 + 5 more

10 Replies

  1. Emily 🍄 Emily 🍄
    the little dark mode/light mode switch is cute!
  2. Ramón Huidobro Ramón Huidobro
    Love the new look on the site! Awesome job 🤩🎉
  3. Zach Leatherman Zach Leatherman
    Excellent write-up!
  4. Max Böck Max Böck
    Congratulations - looks very good! 🎉
  5. Mattia Astorino Mattia Astorino
    Welcome aboard. 🙌🏻
  6. dominik kundel 🐼 dominik kundel 🐼
    Great write up 😊 I have moving my website from Gatsby to eleventy on my todo list forever. Maybe I'll finally get around to it over the holidays
  7. Patrick Foley Patrick Foley
    I’ve been contemplating moving my WordPress blog to Gatsby or Eleventy - so this was super helpful. Thanks!!
  8. Using eleventy as well, can definitely recommend it! It's more or less plain html/css, super quick to set up. Could either use it with markdown or even hook it up to a CMS.
  9. Shahjada Talukdar Shahjada Talukdar
    Will read it ^. Thanks! I was thinking to make new Blog site for me. Is there any good Ready Template for Eleventy which I can use?
  10. Marc Littlemore 🤖 Marc Littlemore 🤖
    Thanks, Amber! I'll have a read as I'm sure it'll be really useful.

1 Mention

  1. Derek Featherstone Derek Featherstone
    🤔

1 Bookmark

  1. Webrocker Webrocker
    Amber writes about her switching the "motor" of her blog/website. What I really like is the in-depth comparison and reasoning which kind of shows that the "rule of least power" should also be more often applied not only to the technology in general, but for our choice of tools as well. And I admire her willingness to face new challenges although she already had invested in a "mightier" solution before. Restarting, relearning and again climb up the new hill is something that not many will do. (no) need to check or ensure that it is server-rendered, is able to be crawled by search engines to allow good search engine optimisation (SEO), or works without JavaScript. Non-SPAs do all of this by default.amberwilson.co.uk