Is Page variable UniqueId unique on filename only or directory/filename?

I’ve come across an issue with the non-uniqueness of this UniqueId when using the isTranslated variable.

On a site with a structure like this

/about/
/about/index.md
/about/index.de.md
/about/… (etc)
/services/index.md
/services/… (etc)

When I include the partial example here https://gohugo.io/content/multilingual/#link-to-translated-content I get issues because the services/index.md has the same UniqueId as the about/index.md and therefore they both thing they have a translation.

Same occurs for any other index.md file.

The workaround at the moment is to make sure the filenames are unique across the whole site, but should the UniqueId not be “more” unique…

Many thanks for any thoughts,
Bruce

The translations doesn’t use the UniqueID to detect translations. Please create an issue on GitHub so we could do something better about this.

@abourget implemented this logic so he may have some insight, but as I read his code:

/sect1/index.md
/sect2/index.de.md

All represents translations of the same content file. I see the problems in your case, but I’m not sure what the “correct” key would be here.

To answer your question: The UniqueID is built on path + filename, so that is unique.

1 Like

thanks bep - will do