How deploy HUGO website on GitPages ( url problem )

Hello
My Website is okay in local.
But on GithubPage i saw the homePage.
And if i click on the menu i go on (https://wilonweb.github.io/blog/) instead https://wilonweb.github.io/hugo-blank-theme/blog/

Do you know what can i do ?

Your GitHub action shows:

image

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: https://wilonweb.github.io/hugo-blank-theme/
  2. Create a GitHub action that uses Hugo instead of Jekyll. See documentation.

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

build
No url found for submodule path 'themes/blank' in .gitmodules
build
The process '/usr/bin/git' failed with exit code 128
build
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

public/
resources/
.hugo_build.lock

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.

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

So i change in config.toml
baseURL = 'https://wilonweb.github.io/hugo-blank-theme-v3/'
I make a .gitignore file with this files

public/
resources/
.hugo_build.lock

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"]
to
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 !!!

my-new-repo
my-github-pages

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.