Enable gzip & brotli for Gitlab pages

With GitLab Pages, you can publish static websites directly from a repository in GitLab.

  • Use for any personal or business website.
  • Use any Static Site Generator (SSG) or plain HTML.
  • Create websites for your projects, groups, or user account. 
  • Host your site on your own GitLab instance or on GitLab.com for free.
  • Connect your custom domains and TLS certificates.
  • Attribute any license to your content.

BUT, by default, the content is not compressed.

illustrative picture


So to enable gzip and brolti, you have to edit the .gitlab-ci.yml file and add somes script : 
.gitlab-ci.yml

 



These scripts will generate files with .gz and .br extensions that Gitlab pages will use to serve them on the internet 



We can see the content-encoding used in the Chrome devtools :





Detailed documentation: https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/user/project/pages/introduction.md 

Thanks to this note for the installation script of brotli: https://gitlab.com/gitlab-org/gitlab/-/issues/297031#note_600821681