How to deploy to GitHub Pages with site in subdirectory

I want to have separate Hugo sites deployed to the same GitHub pages repository in separate subdirectories.

Local Hugo version: 0.146.5

GitHub workflow Hugo version: 0.148.2

I’ve set up the following test repository: https://github.com/kamar535/hugo-gp-test.github.io that deploys to https://kamar535.github.io/hugo-gp-test.github.io/.

In hugo.toml I set baseURL = 'https://kamar535.github.io/hugo-gp-test.github.io/2025', i.e, I want the site in the 2025 sub directory.

As stated in Deployment Scenarios :: Hugo Relearn Theme , in hugo.tom I’ve also set relativeURLs = false.

Locally the site builds and renders with out problems, for example on the following URL on my machine: http://localhost:57862/hugo-gp-test.github.io/2025/.

Based on Host on GitHub Pages, here is my GitHub workflow: https://github.com/kamar535/hugo-gp-test.github.io/blob/main/.github/workflows/hugo.yaml

On GitHub pages, https://kamar535.github.io/hugo-gp-test.github.io/2025 shows 404 and https://kamar535.github.io/hugo-gp-test.github.io/ shows the site without the theme applied.

What am I doing wrong?

In the workflow, do I need to pass the baseURL as a flag to the the hugo command when I’ve already set the baseURL in my hugo.toml?

How do you plan to do that? Will one repository contain two sites? Please explain.

Before I learnt about the multilingual features of Hugo I got the following mulit-site working with Github Pages with one subsite for each language:

GithHub repo: https://github.com/introduktion-till-datorer/introduktion-till-datorer.github.io/

GitHub workflow: https://github.com/introduktion-till-datorer/introduktion-till-datorer.github.io/blob/main/.github/workflows/hugo.yaml.

Deployed sites

Top site: https://introduktion-till-datorer.github.io/

Subsite 1: Introduktion till datorer 2024

Subsite 2: Introduction to IT systems 2024 :: Introduction to IT systems 2024 !!!

For some reason I’m not able to replicate this now with my new test site.

Why not clone the existing site to make a new site?

Also note that the “working” site is a GitHub Pages “user” site, not a GitHub Pages “project” site.

Aha, I cannot test this right now but will try with a GitHub (user/organization) site and see if it makes any difference later.

Also, looking at the original repository, I don’t understand why you need to split this up into three builds.

I wanted one entry site and one subsite for each year. For each year I wanted two languages but since I didn’t know about the multilingual features of Hugo I did it using a separate subsite for each language/year combination.

For my new site I want one entry site and one subsite for each year, using the built in multilingual features of Hugo for each subsite.

Why subsites and not directories? And to answer your original question… you are not setting the publishDir to public/whatever.

The theme I use uses the directory structure to create menus. I want separate menus for each year/language.

I will check out publishDir later when I get back to my development machine.

While convenient in some cases, it’s limiting in others (e.g., your project).

If the menus were based on Hugo’s menu system instead of the theme’s approach, there are easier ways to do this instead of building the site three times.

Finally, see this test project, served from:
https://jmooring.github.io/hugo-forum-topic-55739/2025/.

Starting in Relearn 7.1.0 and further expanded in 7.6.0, you can now configure how navigation menus are created. Instead of the default auto generation from your filesystem structure, you can now also use Hugo menus, let the menu auto generate from a certain page down following your filesystem structure (by using the pageRef parameter), and reconfigure menus for each page.

Everything combined together will generate the whole page in one call to hugo server with the desired menu structure.

Nice.

1 Like

@jmooring setting publishDir did the trick!

@McShelby I love the Relearn theme and the menu features you mention looks like exactly what I need.

1 Like

Just drop me a line in the theme’s issue tracker if you need further help with your configuration.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.