# How to create a unique ID for non-file-based pages

**URL:** <https://discourse.gohugo.io/t/how-to-create-a-unique-id-for-non-file-based-pages/50081>\
**Category:** support\
**Created:** [May 30, 2024, 12:38pm UTC](https://discourse.gohugo.io/t/how-to-create-a-unique-id-for-non-file-based-pages/50081 "2024-05-30T12:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [May 30, 2024, 12:38pm UTC](https://discourse.gohugo.io/t/how-to-create-a-unique-id-for-non-file-based-pages/50081/1 "2024-05-30T12:38:22Z")

</div>

I see that we have the following to add a unique ID to any page that is based on a Markdown file:

```markdown
{{ with .File }}
  {{ .UniqueID }}
{{ end }}

```

Is there something comparable for non-file-based pages or is it “ok” to “just” MD5 a bunch of parameters like this:

```markdown
{{ $unique := printf "%s%s%s" .Kind .Section .Slug }}
{{ md5 $unique }}

```

I am only worried about the performance of this solution, not if people might call me a script kiddie 😉 will it slow down on large sites?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 30, 2024, 1:01pm UTC](https://discourse.gohugo.io/t/how-to-create-a-unique-id-for-non-file-based-pages/50081/2 "2024-05-30T13:01:49Z")

</div>

Within a given language (site) the `.Page.Path` value is unique, and the page does not have to be backed by a file (v0.123.0 and later). If you want a _globally_ unique ID add `.Page.Language.Lang`. Then pass it through [`crypto.FNV32a`](https://gohugo.io/functions/crypto/fnv32a/) to get something short. Something like:

```plaintext
{{ $uid := printf "%s/%s" .Language.Lang .Path | crypto.FNV32a }}

```

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [November 10, 2024, 2:50pm UTC](https://discourse.gohugo.io/t/how-to-create-a-unique-id-for-non-file-based-pages/50081/3 "2024-11-10T14:50:42Z")

</div>

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