Looking for a futureproof UniqueID

It occurred to me when reading the new warnings in Hugo 55 that UniqueID was inherent to the content file.

Which will make it unavailable on pages built from something else than a content file once https://github.com/gohugoio/hugo/issues/5074 ships.

I find myself using .File.Path or .File.UniqueID extensively on partialCached variants.

So From now on what should we use that can work on every kind of pages (content file or otherwise?)

Ideally Page.UniqueID could be maintained and used its own recipe to single out pages.

1 Like

That strongly depends on your project. Here are some things I’d consider:

  • If every source file on your website gets turned into a website page, you can use the page’s final URL. (Assuming you’re not that likely to move URLs.)
  • If every source file comes from a location that’s unlikely to change, you could use the file path as uniqueness indicator. (This includes local content files, but can also include online files, assuming you request each with a specific URL.)
  • If every page has an unique content, you can calculate the content’s hash with the sha function.

But more than this I don’t know. I agree with you that there’s no clean solution yet in place. But I think there will be once we cross that bridge. :slight_smile:

yep, probably what you would put into the canonical link as URL would be the identifying single “slug”.

I have a JSON markdown file and that has an key-value for uniqueid. Even if it is not necessary to generate the html, I can always come back to it later on.

If every source file on your website gets turned into a website page, you can use the page’s final URL. (Assuming you’re not that likely to move URLs.)

URLs do change, and can be swap between two pages.

If every source file comes from a location that’s unlikely to change, you could use the file path as uniqueness indicator. (This includes local content files, but can also include online files, assuming you request each with a specific URL.)

That’s the current system, but only works with local “pages” vs the future “build from data source” pages.

If every page has an unique content, you can calculate the content’s hash with the sha function.

You often find yourself with a lot of pages sharing the same content, mainly because they have no content at all.


There is no future proof solution as of today. I’m assuming the universal recipe for building UniqueID from every page regardless of where they come from might be a combination of several current workaround.

But the idea is to use the same Page’s property when you need to single out a page for partialCached for example, whithout having to build your own recipe depending on the page being local or remote.