I got potentially interesting error when using default render-link.html in multilingual environment.
I got site in Polish / and in English /en/.
On page /o-mnie.md I am referencing to my English site in a link as follows:
Mój język ojczysty to język polski, dlatego moja [strona główna](/) (bez /en) pisana jest po polsku, jednakże zdecydowałem się również na uruchomienie części mojej strony pisanej [w języku angielskim](/en/).
Don’t worry about the context.
Have a look on linking to /en/
[w języku angielskim](/en/)
which returning following error:
Error: error building site: "/idarek_hugo/content/pl/o-mnie.md:1:1": "/idarek_hugo/layouts/_default/_markup/render-link.html:11:16": execute of template failed: template: _default/_markup/render-link.html:11:16: executing "_default/_markup/render-link.html" at <.RelPermalink>: error calling RelPermalink: this operation is not supported
Looks like direct reference to /en/ in links, same as language folders in content causing an issue.
Personally I am using my own render-link.html:
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
But would like to go back to default, but the default is causing error.
In directly such way as mentioned above rarely and can work around that, but other posts returning this issue as well, and need to evaluate what parts of the links are failing. Will come back on it. Thanks.
The .Page.GetPage method (what we use in the embedded link render hook) cannot cross language boundaries, so I need to figure out why the hook isn’t falling back to the provided path.
I checked other posts and found around 6 instances where I referenced [text](/en/) that returned an error.
Interesting is that in /en/about.md using this [in English](/en/) also returns the same error.
Error: error building site: "/idarek_hugo/content/en/about.md:1:1": execute of template failed: template: _default/_markup/render-link.html:11:16: executing "_default/_markup/render-link.html" at <.RelPermalink>: error calling RelPermalink: this operation is not supported
This is not crossing the language boundaries, hence thats interesting.
On my end I will change to full link to fix that temporarily.
I an unable to reproduce the problem, so I must be missing something. Here’s an example:
git clone --single-branch -b hugo-forum-topic-49109 https://github.com/jmooring/hugo-testing hugo-forum-topic-49109
cd hugo-forum-topic-49109
hugo server
Then visit http://localhost:1313/posts/post-1/ and test the links.
Error: error building site: render: failed to render pages: render of "page" failed: "/Users/dariusz/Downloads/hugo-forum-topic-49109/layouts/_default/single.html:3:5": execute of template failed: template: _default/single.html:3:5: executing "main" at <.Content>: error calling Content: "/Users/dariusz/Downloads/hugo-forum-topic-49109/content/pl/posts/post-1.md:1:1": execute of template failed: template: _default/_markup/render-link.html:11:16: executing "_default/_markup/render-link.html" at <.RelPermalink>: error calling RelPermalink: this operation is not supported
Going back to my main website, if I will not have assetDir set like that I got an error:
Error: error building site: render: failed to render pages: render of "page" failed: "/Users/dariusz/Documents/idarek_hugo/layouts/_default/single.html:1:3": execute of template failed: template: _default/single.html:1:3: executing "_default/single.html" at <partial "head.html" .>: error calling partial: "/Users/dariusz/Documents/idarek_hugo/layouts/partials/head.html:12:47": execute of template failed: template: partials/head.html:12:47: executing "partials/head.html" at <minify>: wrong type for value; expected resources.ResourceTransformer; got resource.Resource
If you remove the third “or” condition the problem goes away. The embedded link render hook falls back to these resources lookups because the author might be linking to a file (e.g., PDF) instead of a page.
I understand why you want to map content to assets, but I recommend not doing this because it blurs the line between page and global resources.
If you must map content to assets, do it with language-specific mounts and omit the lang prefix when specifying a global resource path…