RelPermalink: this operation is not supported (on Multilingual reference)

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 config I got:

[languages]
  [languages.pl]
    contentDir = "content/pl"

  [languages.en]
    contentDir = "content/en"

I’ll look into this, but it would be useful to know (in general) how common this is, meaning, how often do you link between two languages?

Also, thank you for always providing a clear and concise description of the issue.

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.

This is probably obvious, but if you are not crossing a language boundary omit the language prefix:

[link to home in the current language](/)

[link to about in the current language](/about)

The only problem that I am concerned about (and will look into) is the inability to cross the language boundary:

[link from pl site to en site](/en/about)
1 Like

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.

Thanks, I managed to reproduce it on your test code.

The difference is that i my config I got specified assetDir that causing this error. Based on your example I add this as follow:

baseURL = 'https://example.org/'

disableKinds = ['rss','sitemap','taxonomy','term']

assetDir = "content"
defaultContentLanguage = 'pl'
defaultContentLanguageInSubdir = false

and that thrown an error:

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

Thats refers to this part in head.html file

  {{ $style := resources.Get "css/style.css" | minify | fingerprint }}
  <link rel="stylesheet" type="text/css" href="{{ $style.Permalink }}" media='all' fetchpriority="highest">

That is… unexpected.

This is the embedded link render hook:

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…

[[module.mounts]]
source = 'assets'
target = 'assets'

[[module.mounts]]
source = 'content/en'
target = 'assets'

[[module.mounts]]
source = 'content/pl'
target = 'assets'

…but I still don’t like it.

1 Like

I was thinking about returning to using /assets folder, but need to think how this will affect my other things.

I will need to think about it.

Thanks for your help.

1 Like

Just a follow up.

I resigned from:

assetDir = "content"

and moved assets into assets folder. Issue sorted. Thanks.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.