How deploy HUGO website on GitPages ( url problem )

My Website is okay in local.
But on GithubPage i saw the homePage.
And if i click on the menu i go on ( instead

Do you know what can i do ?

Your GitHub action shows:


The only reason that anything is working is because you’ve included the public directory (which you created when you ran Hugo locally) in your repository.

You need to:

  1. Change the baseURL in your site configuration to match the base URL of your site:
  2. Create a GitHub action that uses Hugo instead of Jekyll. See documentation.

I folow the step of the documentation but my add worflow have an error :

No url found for submodule path 'themes/blank' in .gitmodules
The process '/usr/bin/git' failed with exit code 128
The process '/usr/bin/git' failed with exit code 128

Your repository is fouled up. Do this locally:

1) Create a .gitignore file in the project root


2) Clean up the repository

git rm -rf public
git rm -rf themes/blank
git rm -rf --cached themes/blank
git add -A
git commit -m "Fix everything"
git push

Now the GitHub Action will complete, but your theme has some issues.

On GithHub pages you are serving your site from a subdirectory. The references to images in your front matter are relative to the host root, not the root of your site. Either ask the theme author to modify the theme so that it works when served from a subdirectory, or make the changes shown here.

I created a new repo because I can’t clean my branches.

So i change in config.toml
baseURL = ''
I make a .gitignore file with this files


i created gh-pages
inside the branch i put the command hugo

The website is now working expect images.

So I change in my front matter
images: ["/images/blog/enfantDuRetro.jpg"]
images: ["images/blog/enfantDuRetro.jpg"]
and on another post
images: ["static/images/blog/enfantDuRetro.jpg"] ( to make a test )

I’m the creator of theme ( i follow a tutorial to make my first theme and learn hugo with that )
what do I have to modify so that my theme works when it is served from a subdirectory ?

And now i work on the branch gh-pages
I have to merge it with my branch main ?
( i’m affraid to “broke” my branch again :confused: )

Thanks a lot !!!


You need to let Hugo determine the image URL.

If you want to keep your images in the static directory, and you don’t want to mount the static directory to the assets directory, you need to use the relURL or relLangURL function to resolve the front matter image path(s) to the correct URL.

The image path(s) in front matter must NOT begin with a slash, and must NOT include the static directory:

images: ["images/blog/enfantDuRetro.jpg"]

Instead of doing something like this (incorrect):

{{ with .Params.images }}
  <img src="{{ index . 0 }}" alt="">
{{ end }}

Do this (correct):

{{ with .Params.images }}
  <img src="{{ index . 0 | relLangURL }}" alt="">
{{ end }}

If it were my theme, I would (maybe) use the static directory for things like favicon.ico and robots.txt. Then I would use either page bundles or the assets directory to store images. In both cases the images are easily captured as resources, allowing you to resize, etc. Using the static directory is an outdated construct.

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