# Looking for a futureproof UniqueID

**URL:** <https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936>\
**Category:** support\
**Created:** [May 28, 2019, 10:18am UTC](https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936 "2019-05-28T10:18:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [May 28, 2019, 10:18am UTC](https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936/1 "2019-05-28T10:18:37Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [June 4, 2019, 5:38pm UTC](https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936/2 "2019-06-04T17:38:21Z")

</div>

> [@regis](#):
>
> So From now on what should we use that can work on every kind of pages (content file or otherwise?)

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](https://gohugo.io/functions/sha/).

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. 🙂

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [June 4, 2019, 5:42pm UTC](https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936/3 "2019-06-04T17:42:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Leopo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/leopo/32/8580_2.png) [@Leopo](https://discourse.gohugo.io/u/Leopo)\
**Post date:** [June 4, 2019, 6:08pm UTC](https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936/4 "2019-06-04T18:08:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [June 6, 2019, 12:23am UTC](https://discourse.gohugo.io/t/looking-for-a-futureproof-uniqueid/18936/5 "2019-06-06T00:23:19Z")

</div>

> 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](https://gohugo.io/functions/sha/).

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.
