The reason I want to move to Hugo is because it is more modern and flexible compared to my Jekyll site. Also, there is a problem of adding sitemap.xml to Google Search console. I think google has been limited the crawling process on Github Page since 2023.
The instruction is quite clear on their site https://gohugo.io/host-and-deploy/host-on-github-pages/
First, as always we need to create a github repo, and clone it in our local machine.
Next, we will need to create a Hugo project. I’m using Windows so I will select Extended-edition here. To access PowerShell, from command prompt we can type pwsh
$env:CGO_ENABLED=1; go install -tags extended github.com/gohugoio/hugo@latestAfter install Hugo, we will need to get theme. In this example, I will use Book theme. A simplest way to get book theme is to use git submodule
git submodule add https://github.com/alex-shpak/hugo-book themes/hugo-bookThen, inside the config file hugo.toml we will add the theme
theme = 'hugo-book'At this stage, we can see the website locally by running hugo server in pwsh. Now, we need to setup Github Action config to build and deploy the site. We can follow step 2 here.
Also, please don’t forget to change value in hugo.toml
baseURL = 'https://username.github.io/'
locale = 'en-us'
title = "name of your site"
theme = 'hugo-book'
enableRobotsTXT = false #--> need to add robots.txt in static folder
[params]
# check here for more https://book.alxs.dev/docs/getting-started/configuration/
BookFavicon = "favicon.ico" At this step, the website is ready to be pushed. If deployment is failed you can try rerun the failure steps. Now to solve the original problem: “sitemap.xml” could not be fetched, we will need to add a custom domain.
There are many places to get domain. After that, we can add these in our custom domain record.
| Type | Name | Priority | TTL | Data |
|---|---|---|---|---|
| A | @ | N/A | 4 hrs | 185.199.108.153 |
| A | @ | N/A | 4 hrs | 185.199.109.153 |
| A | @ | N/A | 4 hrs | 185.199.110.153 |
| A | @ | N/A | 4 hrs | 185.199.111.153 |
| CNAME | www | N/A | 4 hrs | username.github.io |
| AAAA | @ | N/A | 4 hrs | 2606:50c0:8003::153 |
| AAAA | @ | N/A | 4 hrs | 2606:50c0:8002::153 |
| AAAA | @ | N/A | 4 hrs | 2606:50c0:8001::153 |
| AAAA | @ | N/A | 4 hrs | 2606:50c0:8000::153 |
We also need to add Custom domain in our Github repo. The path usually, repo > Settings > Pages > Custom Domain
We can fill in www.yourdomain.com or just a root domain yourdomain.com
Good luck!