All Articles

Why I moved to Gatsby

Photo by Pereanu Sebastian on Unsplash unsplash-logoPereanu Sebastian

Since I first felt the urge to write stuff online (a.k.a blogging), I was repelled by the mainstream platforms back then. Let’s face it: for developers, Wordpress CMS interface is not friendly. Things are slow, refresh is painful and you get the feel you spend more time configuring plugins, themes and updating than doing what you wanted in the first place: write.

Years ago I had this great idea: writing all using the MarkDown sintaxe, and have code a translator to HTML. This way I would avoid HTML, web interfaces and even databases! Happens that the ideia was good, but it was not all new. People were doing it, and I was mesmerized by some nice projects that could free me from all the distractions while reading. The expressions content-centric really got me going (and still do, by the way).

At the time, I chose Grav to try. I based this decision on a few assumptions:

  1. Familiar language (Grav is written in PHP).
  2. No databases.
  3. MD sintax for both pages and posts.

And for years I could come up with an idea, write it down using my usual IDE, and push it to an Github repository. And that would be the end of it. I even set a hook that would make the repo automatically sync with the blog, both ways.

But some things kept bothering me. It was almost perfect, but:

  1. The site was slow. Content was loading painfully slow for a website without a database, and I could not understand why. From time to time I got emails from people telling me the site seemed down.
  2. The ecosystem is not healthy. This basically means the plugins are often poorly documented and maintained.
  3. The command line interface and many core functions are poorly documented. That forced me to use the CMS admin for things like backups, updates and even some SEO.
  4. Grav’s design does not allow me to code. Developers mostly can only change templates without hacking the core components.

Many of this points might be changing, and it is clear how the Grav community is growing. But it is not vivid, exploding. It is changing slowly, or at least slower than I could wait. I had to come with a solution.

Goodbye Grav, hello Gatsby.

I met Gatsby first while doing some research on documentation websites. That is also and ancient problem, keeping your docs up to date while evolving the code, without much trouble. The first thing that jumped at me was the community. Only a strong community can support such vast and well organized documentation, tutorials, as well so many small and well focused plugins. And the so called starters (basically templates) help you to spin off.

The main conceptual difference from grav is that you control not only the content, but all the pages, from your code. So if you know at least some (like me) about React you can do anything. Basically everything from React ecosystem is within an arm’s reach (or a NPM install / Yarn add ) from your project. That is a huge difference in practical terms, since you can do a lot more using more mature and battle tested components.

The build is fast, and very easy to deploy, especially with Gitlab CI or GitHub Actions. The result is an minimal bundle with JS/CSS/HTML and medias, ready to work in basically every place without anything else. Just serve the files using any web server, like Apache or Nginx.

Well, do you like CMS? Or at least you want to be able to use them, for example when your project grows and you will have non tech people to write content? Not a problem. When I first met Gatsby I was looking for writing in MD. But that is not a ground rule, a core restriction of it. The idea is “pull content from everywhere”. You can easly integrate from legacy stuff (like an old Wordpress powered platform), databases, and newer CMS projects, like Ghost or Netlify.

What are you going to do with the old content?

That is a good question. Because this change is also conceptual. For instance, I’m not writing in portuguese anymore, so I can’t just bring all MarkDown files and be done with it. I’ll try to keep old links working, since cool URIs don’t change, with a banner pointing out for the new version (at least for now). I also intend to translate some of the most popular posts so I can reach and help more people out. #HackNews are going to continue (now in english). Anyway, for now, the old site still there.

Conclusion

Grav is far better than ancient projects like Wordpress, but still lacks of community support to be great. And that is what makes Gatsby so great. Also, some software design concepts make it easier to maintain and scale, when/if the time is write. Those aspects make Gatsby a good tool for my purposes and surely a nice project to be involved.