Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Edit this page' links using outdated Hugo configuration #48

Open
Teebusch opened this issue Nov 4, 2021 · 1 comment
Open

'Edit this page' links using outdated Hugo configuration #48

Teebusch opened this issue Nov 4, 2021 · 1 comment
Labels
wontfix inactive issues

Comments

@Teebusch
Copy link
Contributor

Teebusch commented Nov 4, 2021

At the bottom of each page on the website there is an edit this page link. The link is generated automatically by the hugo book theme that we use. Specifically, the link is generated in the footer layout, as follows:

<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ .Site.Params.contentDir | default "content" }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">

For these links to work with our site, {{ .Site.Params.contentDir | default "content" }} should return content. staticDir is a Hugo defined variable. In a standard Hugo configuration (at least prior to v0.56) it is set to 'content' by default (see docs).

However, in our case .Site.Params.contentDir seems to return an empty string, which means that the snippet returns an empty string and the edit links do not work (they point to the wrong URL). I believe this is because we are using Hugo ≥0.56 and "mounts", which makes the default parameters obsolete. I believe this is also what's pointed out in the Hugo docs, albeit not very clearly:

When you add a mount, the default mount for the concerned target root is ignored: be sure to explicitly add it.

I've tried to add a mount for 'content' but it did not affect the url that was generated by the snippet. I think it's because the snippet explicitly asks for the .Site.Params.contentDir parameter and doesn't care about the mounts.

I eventually got the links to work by setting contentDir = 'content' in our site's config.toml
This works, but it goes against the recommendations in the Hugo docs:

you should not have both: if you add a mounts section you should remove the old staticDir etc. settings

So we shouldn't be using mounts and contentDir site params in the same configuration. It appears to work for our purposes and it will probably continue to work unless we update Hugo or the theme. The reason I'm leaving this issue here is that if something breaks, people know where to look. Or perhaps, someone wants to try to configure this "the proper way" or raise an issue with the theme.

@Teebusch Teebusch added the wontfix inactive issues label Nov 4, 2021
@lexnederbragt
Copy link
Contributor

Thanks, @Teebusch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix inactive issues
Projects
None yet
Development

No branches or pull requests

2 participants