REF_NOT_FOUND in multilingual when language of calling post is missing in target post


I’m building a multilingual site and am using the ref shortcode for links between posts.

Everything works fine except when the target post does exist in the language of the origin post:

  post_origin/  <--- the link is here
  post_target/     <--- and I would like to link here

I expected Hugo to fallback from en to the default language and find even though the calling page is in a different language. But this doesn’t seem to happen.

The documentation for multilingual themes support suggests that some care must be taken when building urls and lists some rules. I wonder how can these rules be applied to the rel shortcode.

Can someone help me figure this out? Am I doing something wrong?

Meanwhile I temporarily configured refLinksErrorLevel = WARNING for now in config.toml. But this won’t be acceptable when the site goes live.

Thanks in advance,

Hello, can anyone help me with this? Thanks.

I had abandoned this project over one year ago but am now coming back to it.
I found that this issue is still happening.
Can someone please suggest a solution or workaround?

It is not always guaranteed that all pages will be translated in all languages. If one page in one language is missing then I believe HUGO should link back to the page in the default language.

Please advise.


Roll your own shortcode.


{{- $path := .Get 0 -}}
{{- with site.GetPage $path -}}
  {{- .Permalink -}}
{{- else -}}
  {{- with .Page.Sites.First.GetPage $path -}}
    {{- .Permalink -}}
  {{- else -}}
    {{- errorf "The %q shortcode was unable to resolve %q to a page. See %s" .Name $path .Position -}}
  {{- end -}}
{{- end -}}
1 Like

Oh my! Such a simple and elegant solution. Thank you!