I am trying to use Hugo Xmin to create a static site. My site will be hosted in the gh-pages of my repository, therefore the final URL will look like:
https://myuser.github.io/myrepo/
Note At my current stage, I haven't modified any file in the example site that comes along with the theme, so basically the site I am deploying is the same exact in the original repository.
In my config.toml
I have set:
baseurl = "https://myuser.github.io/myrepo/"
Because with baseurl = "/"
my links to the static CSS files in the <head>
were not working and the site looked messy. By specifying the base url, CSS is loaded fine, but then top bar links are broken because this is what is generated:
<li>
<a href="/myproj/myproj/about/">About</a>
</li>
Why is the generated URL looking so odd? The repository name is duplicated.
The theme example site, in /content/_index.Rmarkdown
has a few links at the end:
You can also visit the list page of a single section, e.g., [posts](/post/), or [notes](/note/). See the [About](/about/) page for more info.
Those do not work in my case because the URL that is generated is:
<a href="/post/">posts</a>
Which will redirect the user to: https://myuser.github.io/post/
which is wrong. Basically this theme does not work when the hosting domain has a subfolder. Or am I missing anything here?
By investigating a bit I can see the theme defines those links like the following:
<ul class="menu">
{{ range .Site.Menus.main }}
<li><a href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end }}
</ul>
Function relURL
is taking what comes after the hostname ans spitting it twice in the generated URL :(
The behavior of relURL
seems to have changed since a certain version of Hugo (I don't know which). Anyway, you can remove the leading slashes in those menu items, e.g., change
[[menu.main]]
name = "About"
url = "/about/"
to
[[menu.main]]
name = "About"
url = "about/"