Guilherme Raduenz

Moving away from GitBook to Hugo

I recently moved my website away from GitBook, and this is the first post on the new platform.


The platform is great, and I will be using it for documentation projects.

My initial goal was to focus on content writing instead of coding a website from scratch, but I wanted to have control over the data (in a GitHub repository).

I wrote two articles there about stuff I was dealing with recently:


However, there was a simple problem on the platform that I never liked. When configuring a space, I have to choose a subdomain for it ( without being able to use the root domain (

My approach to this was to:

It worked very well, but I didn’t like it: it was a workaround, I just wanted it to literally bind the site to the root domain.

Also, there are some limits on the Cloudflare workers (100k requests/day) that contributed to the decision to get away from it.

Choosing a new platform

When choosing a new platform for the website, some requirements had to be met:

I know there are many options, but after some research my choice was Hugo.

I was able to build the whole website within a few hours, and its source code is also available on GitHub.

Extra: Cloudflare worker

In case you ever want to handle the problem with GitBook on Cloudflare like I did, here’s the code for the worker:

 1export default {
 2  async fetch(request, env, ctx) {
 4    // Fetch from the gitbook website
 5    const url = new URL(request.url);
 6    url.hostname = ''
 7    const res = await fetch(url);
 9    const contentType = res.headers.get('Content-Type');
10    const isHtml = contentType && contentType.startsWith('text/html');
12    // If it's not HTML, just return the response
13    if (!isHtml)
14      return res;
16    // Otherwise, goes ahead with fixing meta tags for LinkedIn
17    var rewriter = new HTMLRewriter()
18      .on('meta', {
19        element(element) {
20          const name = element.getAttribute('name');
21          element.setAttribute('property', name);
22        }
23      });
25    return rewriter.transform(res);
26  },


Reply to this post by email ↪