gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.63k stars 7.45k forks source link

CanonifyUrls does not work with ExecuteAsTemplate #8178

Closed xoxys closed 2 years ago

xoxys commented 3 years ago

We use resources.ExecuteAsTemplate in a Hugo theme to render a JS file containing Hugo template strings. Within this file relURL and resource.RelPermalink is used but the URLs to these files are not made canonical when canonifyURLs is enabled. The whole theme is using relURL and produces the expected canonicalized URL's except when within ExecuteAsTemplate source. While the theme works with relULR by default without issues, it should be possible to change this behavior by the user if someone wants/has to use canonicalized ULRs.

The expected result is canonifyURLs=true works the same for both cases.

Full discussion in the forum https://discourse.gohugo.io/t/canonifyurls-does-not-work-with-executeastemplate/30852 Theme source: https://github.com/thegeeklab/hugo-geekdoc/blob/master/assets/js/search.js#L17-L20

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.80.0-792EF0F4 linux/amd64 BuildDate: 2020-12-31T13:37:58Z

Does this issue reproduce with the latest release?

Yes

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.