"Hugo + GitLab Pages" is the way to go for building a Git-based Jamstack blog sites
Tags: hugo, gitlabpages, jamstack, tutorial
Published: 2022-07-23 13:01:00

If you are looking to build a free, serverless, Git-based Jamstack blog site, I recommend Hugo + GitLab Pages as the platform. I will explain why, comparing it to other leading static site generator/platform services.

Below is a diagram of the components of the Git-based Jamstack service set. Here I compare the static site generator, which is the heart of Jamstack, and the Git/build/hosting platform services. Note that the optional dynamic content service is not included because I want to compare them as a basic platform.

![Service architecture for serverless blogging environment : Components of Git-based Jamstack](https://ayaco.gitlab.io/zerogravity/en/docs/overview/hugoongitlabpages/feature.svg)

## Static site generator comparison

Compare the top four [Site Generators - Jamstack.org](https://jamstack.org/generators/).

| Softare | [Next.js](https://nextjs.org/) | [Hugo](https://gohugo.io/) | [Gatsby](https://www.gatsbyjs.com/) | [Jekyll](https://jekyllrb.com/) |
| --- | ---: | ---: | ---: | ---: |
| GitHub star count[^star] | 82068 | 57301 | 52420 | 44171 |
| Theme count[^theme] | 31(unknown) | 126(414) | 231(112) | 325(459) |
| View framework | React | Go template | React | Liquid |
| Build speed(256 pages)[^build] | 15.11s | 0.11s | 33.22s | 0.89s |
| Page load time suitability(LCP)[^lcr] | 25.8% | 70.3% | 41.2% | 76.4% |
| Layout collapse resistance(CLS)[^lcr] | 50.0% | 74.2% | 65.7% | 81.1% |
| Web resource size[^lcr] | 1838KB | 1025KB | 1739KB | 753KB |
| ├ JS size | 746KB | 177KB | 645KB | 129KB |
| └ CSS size | 14KB | 29KB | 1KB | 23KB |

Opinions may differ as to whether one prefers the clarity of template languages such as Go template and Liquid or the flexibility of programming frameworks such as React, but I think Hugo is the best for the following reasons.

- Fast build.  
  Build speed is very important, both to meet the build time limit set by the build container service and to quickly check the operation and preview submissions after view program changes.
- High core web vitals (Google's viewer experience index).  
  Because it uses more CSS than JS, it can create a site with a high viewer UX, with faster page loading/display and less layout shifting after display.
- A full range of themes are available.  
  Even if you don't know Go template, you can enjoy changing the look of your site by simply choosing your favorite theme.

## Comparison of platform services for a serverless, Git-based Jamstack blogging environment

### Git + Build + Hosting platform service comparison

This is an all-in-one platform service that allows you to build a stand-alone Git-based Jamstack blog site. Compare the two leading ones.

| Vender | [GitHub](https://github.com/) | [GitLab](https://about.gitlab.com/) |
| --- | --- | --- |
| Product plan | [Free](https://github.com/pricing) | [Free](https://about.gitlab.com/pricing/) |
| Project type | [Pages](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages) | [Pages](https://docs.gitlab.com/ee/user/project/pages/) |
| Git publicness | [Public](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages) | [Public, Private](https://forum.gitlab.com/t/what-are-the-restrictions-for-gitlab-pages-sites/15067/6) |
| Git capacity limit | [1GB/repository](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages#usage-limits) | [5GB/repository](https://about.gitlab.com/pricing/)([currently 10GB](https://about.gitlab.com/pricing/#what-counts-towards-my-storage-limit)) |
| Git transfer limit | (unknown) | [10GB/month](https://about.gitlab.com/pricing/) |
| Build time limit | [Unlimited for public repository](https://github.com/pricing) | [50000 minutes/month for public repository](https://about.gitlab.com/pricing/#is-there-a-different-ci-cd-minutes-limit-for-public-projects), [400 minutes/month for private repository](https://about.gitlab.com/pricing/) |
| Build count limit | [10 times/hour](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages#usage-limits) | [Unlimited](https://forum.gitlab.com/t/what-are-the-restrictions-for-gitlab-pages-sites/15067/6) |
| Hosting capacity limit | [1GB/project](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages#usage-limits) | [Unlimited within the project's repository capacity](https://forum.gitlab.com/t/what-are-the-restrictions-for-gitlab-pages-sites/15067/6) |
| Hosting bandwidth limit | [100GB/month](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages#usage-limits) | [Unlimited](https://forum.gitlab.com/t/what-are-the-restrictions-for-gitlab-pages-sites/15067/6) |
| Static site generator template | Jekyll | Gatsby, Hugo, Jekyll, GitBook, Hexo etc. |
| Commercial use | [Not acceptable](https://docs.github.com/ja/pages/getting-started-with-github-pages/about-github-pages#prohibited-uses) | [Acceptable](https://docs.gitlab.com/ee/user/project/pages/) |

GitLab, which supports private repositories and provides templates for various static site generators, is easier for many people to use. Also, if you want to generate revenue through advertisements/affiliates, GitLab is safer for commercial use (advertisements/affiliates may be considered commercial).

### Build + Hosting platform service comparison

A build+hosting-only platform service used in conjunction with another Git service. Compare the two leading ones.

| Vender | [Netlify](https://www.netlify.com/) | [Vercel](https://vercel.com/) |
| --- | --- | --- |
| Product plan | [Starter](https://www.netlify.com/pricing/) | [Hobby](https://vercel.com/pricing) |
| Build time limit | [300 minutes/month](https://www.netlify.com/pricing/#features-build-minutes) | [6000 minutes/month](https://vercel.com/docs/concepts/limits/overview#typical-monthly-usage-guidelines) |
| Build count limit | (unknown) | [100 count/day](https://vercel.com/docs/concepts/limits/overview#general-limits) |
| Hosting capacity limit | [Unlimited](https://answers.netlify.com/t/are-there-storage-limits-on-the-starter-plan/5368) | (unknown) |
| Hosting bandwidth limit | [100GB/month](https://www.netlify.com/pricing/#features-bandwidth) | [100GB/month](https://vercel.com/docs/concepts/limits/overview#typical-monthly-usage-guidelines) |
| Commercial use | [Acceptable](https://answers.netlify.com/t/can-we-use-netlify-free-plan-for-commercial-purposes/41545) | [Not acceptable](https://vercel.com/docs/concepts/limits/fair-use-policy#commercial-usage) |

Assuming no commercial use, Vercel has a build time of 6,000 minutes/month. In cases where GitLab Pages build time of 400 minutes/month is not enough, using Vercel in combination with GitLab Pages may be an option.

## Conclusion : Hugo + GitLab Pages is recommended

For a static site generator, Hugo has the fastest build speed and high core web vitality, and for a platform service, GitLab Pages supports private repositories and is safe for advertisements/affiliates, a combination that I think is necessary and sufficient.

The small build time of GitLab Pages is a concern, but it has not been a problem in my experience. When I spent 3 hours on weekdays and 8 hours on weekends for site renewal, the build time was about 250 minutes/month, which is 63% of the maximum build time of GitLab Pages.

Note that the build time varies greatly depending on the theme you use, because of different circumstances such as updating dependencies by git sub moddule, installing additional packages, calling PostCSS from Hugo, and so on. The 250 minutes/month above is based on using Docsy as the theme.

| Theme | Beautiful Hugo | Docsy |
| --- | ---: | ---: |
| Build time/times | 17s | 45s |
| ├ Docker startup | 9s | 13s |
| ├ Pull from Git | 1s | 13s |
| ├ Hugo preparation | 1s | 11s |
| ├ Hugo execution | 0s | 3s |
| ├ Artifacts registration | 2s | 3s |
| ├ Work area cleared | 1s | 1s |
| └ Others | 3s | 1s |



[^star]: The number of GitHub stars is the value as of 2022/02/27.
[^theme]: Number of themes is the value of [Jamstack Themes](https://jamstackthemes.dev/theme/) as of 2022/02/27. The numbers in parentheses indicate the number of themes registered at each official site.
[^build]: Build speeds are from [Comparing Static Site Generator Build Times](https://css-tricks.com/comparing-static-site-generator-build-times/). Note that this is the time for the static site generator only and is part of the range that the build container measures as build time (e.g., pull/launch Docker image for build, pull source from Git, launch static site generator...).
[^lcr]: LCP/CLS/resource amounts, etc. from [Jamstack - Web Almanac](https://almanac.httparchive.org/en/2021/jamstack#largest-contentful-paint).