Hi,
I hope you are doing well. Apologizes by advances for this post, but I came accross many posts (such as this one) and I still could not solve my issue.
Problem statement
My problem is that file true locations and href are not corresponding.
Context
- I created my first Hugo blog on GitHub using the Anake theme, and I successfully deployed it on GitHub Pages.
- I also bounded the blog to a custom domain (weekly-tech.io)
- My blog has a subfolder baseURL:
https://tdard.github.io/weekly-tech
- Every href that is used employs resources RelPermalink property to obtain links. Obtained hrefs are relative to
https://tdard.github.io
and nothttps://tdard.github.io/weekly-tech
(it is a problem, isn’t it?) - No
<base>
tag has been added
Here is the config.toml
file:
baseURL = 'https://tdard.github.io/weekly-tech'
languageCode = 'fr-FR'
title = 'Weekly tech'
theme = 'ananke'
Paginate = 10
summaryLength = 40
Details and examples
My issue is that all the links are broken, meaning:
- The impossibility to navigate
- No CSS
- No JS
When I reach the website address, I can see the index.html page.
But when I click on the link of one post, it adds the subfolder as a prefix to the address (i.e. http://weekly-tech.io/weekly-tech/posts/2023-s1/ ) and therefore the page is not found.
When I remove the subfolder from the address, the post can be found: http://weekly-tech.io/posts/2023-s1/.
Here is an example of how I add a CSS file using a template located in assets:
{{- $styles := resources.Get "main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}">
This resource is located at http://weekly-tech.io/main.min.<hash>.css
, but the (relative) href displays /weekly-tech/main.min.<hash>.css
, meaning that the full href is http://weekly-tech.io/weekly-tech/main.min.<hash>.css
.
To make this work, it seems that:
- Either I should ensure that the location of resources (other than the main index.html) is in a weekly-tech folder
- Either I should make sure to remove the first /weekly-tech/ from href using RelPermalink
But none of the solution looks clean.
Do you know how I could correct this?
Kind regards,
Tristan