Proud to present my new website developed with Hugo and hosted on GitHub Pages and discuss here how I built the site.
How did I build this website?
NOTE: I am not trying to write a full tutorial, there are (too) many already out there. I am outlining how I went about building this website and I am documenting some things I had to learn the hard way, i.e. lost too much time for something that was relatively simple in hindsight but I just did not find it easily in the existing tutorials.
HUGO
I am using Hugo since it’s actively being developed, has various themes, and builds a static website from source files on your computer. You do not get locked into a hosting service’s proprietary publishing software or templates.
I further prefer the command-line nature of building the site with the hugo command and the publication of the site also happens from the commandline with git. I edit the ‘source’ files (.md, .yml, .html, …) with vscode but you can use anything else.
Template
First, I googled site:edu “powered by Hugo” to see what templates academics are using. The ones that I liked were ‘PaperMod’, ‘Hugo Cards’, and ‘Hugo Coder’ for a personal profile site; ‘Docks’ and ‘Academic Theme` are probably more suited for a research group site.
I settled for PaperMod and more specifically used the modified version by Pascal Michaillet; he provides a template website, that I downloaded through a zip file1 and unzipped on my computer. The template already has the correct hugo folders, includes a config.yml and includes the theme files, so it is very easy to get started. From here on, it was mostly editing the existing files and adding my own materials.
Configuring the Site
config.yml is the key file you need to customize from the template to make the site your own.
baseURLis important; it is the base URL for where you will be publishing the site; it needs to end with a/.menuis for the menu in the upper right corner of the pagesparams:–>profileMode:–>enabled: trueis what makes the root page a picture with some text and buttons.params:–>socialIcons:show up on the profile page.
Building Pages
-
You need to get familiar with Markdown since that is the easiest way to write new content for Hugo. You can also have
htmlfiles and evenorgfiles I believe. -
When you want to create a page, you have to put a file in the
contentsfolder. E.g. if you make a filefirst_page.mdincontents, then when you runhugo buildyou will get a file/first_page/index.htmlgenerated in the build folder (typicallypublicordocs), which can be accessed as<baseURL>/first_pageonce you post the site. -
The
.mdfiles need to have the right heading to get processed byhugo:
---
title: "First Page"
date: 2025-01-25
description: "First Page"
---
-
There are hugo commands to create new contents like
hugo new -
Static material goes into the
staticfolder under the correct subfolder; so, e.g., images for thefirst_page.mdcan be put instatic/first_page/img/first_image.pngand can then be added tofirst_page.mdwith -
I had an older website and at this point have in many cases brought over the
htmlfiles and converted them inmdfiles with the right header, but still the html inside; see e.g. Publications
Some Tips
-
hugo serveris very handy to view your webpages in a browser as you are writing them; some times the changes ‘do not take’, so you have to exit it and restart it. -
The links to other pages or static material are sometimes a bit hard to figure out, but
hugo servercan be quite helpful with that. -
Two ways of putting a figure in an .md file:
is standard markdown,\{\{< figure src=\"../images/photo_jan_2011.png\" height=\"200px\">\}\}is a hugo directive that allows you to control the size of the figure; the\do not need to be included, I needed them here to avoid errors for this page.
-
You can have links to headers in md pages; the link on top will point to the header below:
| [Books](#books) |
## Books
- A first book to read
GitHub Pages
I am using GitHub pages to host this site at https://peterkinget.github.io (so this my baseURL with an extra / at the end).
You need to be familiar with GitHub repositories to understand the notes below.
Repositories
-
I have a public repository
peterkinget.github.ioas GitHub recommends. I am only publishing the final site there though, not the original, full hugo site. -
I have a separate ‘source’ repository
hugo-sitethat I use to sync the full hugo folder on my computer. That folder gets published also ashttps://peterkinget.github.io/hugo-site/(again, make sure the baseURL is correct inconfig.yml). I find it useful to keep things separate and can verify updates before posting them on my actual site.
Publishing a repository
-
In Github go to your repository –> Settings –> Pages –> ‘Deploy from a branch’ –>
main&/docs. If all goes right, GitHub puts the URL on the top of this settings page, but you might have to wait a bit. -
Check the ‘Actions’ tab for the repository to see if the publishing was successful.
-
You need to instruct hugo to build in the
/docsfolder by havingpublishDir: docsnear the top of yourconfig.ymlsince GitHub can only serve your site from a/docsfolder. -
Since my base URL is set to
https://peterkinget.github.io/hugo-site/in my ‘source’hugo-siterepo, I have to tell hugo to build the site with a different baseURL when I am ready to upload it to thepeterkinget.github.iorepo usinghugo build --baseURL "https://<the correct baseURL>/"; then clear ( withrm) thepeterkinget.github.iofolder on my computer andmvthe files fromhugo-site/docsinto thepeterkinget.github.io/folder, followed by thegitcommands to add, commit, and push that folder to the repository.
Some Tips
-
When you update your repository on GitHub, it will start processing the files right away. To see the progress and any possible issues look at
Actionsfor your repository. -
If you decide to start a hugo site from scratch (and not from a template site like above), then you will likely install the ’theme’ using git. Make sure to add it as a submodule, since you will sync your overall folder to your own repository. You will need to use something like
git submodule add <URL_for_theme_repository> <theme_folder>and notgit clone, otherwise GitHub will later have trouble publishing your site (seeActionsmentioned above). -
You can use GitHub workflows to make the hugo site from the repository, but I have not tried that yet. Here is a link I am saving for possible future use.
TO-DO
- Understand the ‘posts’ and ‘posting’ better, including
tagsandcategories. - Add commenting to posts using
utterances.
-
By using zip instead of
git cloneit’s easier to then later connect the folder to your own GitHub repository. ↩︎