# Kirby3 AutoID - unique ID for pages, files and structures to create safe relations

**URL:** <https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572>\
**Category:** Plugins\
**Tags:** v3\
**Created:** [October 1, 2021, 5:30pm UTC](https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572 "2021-10-01T17:30:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [October 1, 2021, 5:30pm UTC](https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572/1 "2021-10-01T17:30:28Z")

</div>

> I am creating posts for [my plugins](https://getkirby.com/plugins/bnomei) to make it easier to find them using the forum search and not just the docs search.

My [AutoID Plugin](https://github.com/bnomei/kirby3-autoid) adds an automatic unique ID for Pages, Files and nested Structures including performant helpers to retrieve them to your Kirby installation. Bonus: Tiny-URL.

Kirby does not (yet) have a persistent unique id for Page- and File-Objects, which could be useful in various situations. Using the `$page->id()` will not solve this since it changes when the `$page->slug()` / `$page->url()` changes, Files could get renamed. What would be needed was a Field defined in Page/File Blueprints where that unique id will be stored and some logic to generate it automatically (using Hooks). Thus the idea of `autoid` was born.

To sum it up with the AutoID Plugin you can solve problems like these:

- Automatically get an unique id for each Page/File which has the `autoid` Field in its Blueprint.
- Store a reference to a Page/File which does not break if that objects or parents are renamed.
- Get a Page/File quickly using that reference.

> **[Home](https://github.com/bnomei/kirby3-autoid/wiki/)**
>
> Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL. - bnomei/kirby3-autoid

```yml
 content:
  type: fields
  fields:
    text:
      type: textarea
    autoid: # <-------
      type: autoid  

```

```yml
special:
  label: Special Child
  type: checkboxes
  options: query
  query:
    fetch: page.children.filterBy("template", "special")
    text: "{{ page.title }}"
    value: "{{ page.AUTOID }}" # uppercase is recommended

```

```php
$autoid = 'any-autoid-value';

$result = autoid($autoid); // global helper function
// or
$result = $page->myFieldWithAutoIDReference()->fromAutoID(); // fieldMethod

if(is_a($result, 'Kirby\Cms\Page')) {
    // got a Page
} elseif(is_a($result, 'Kirby\Cms\File')) {
    // got a File
} elseif(is_a($result, 'Kirby\Cms\StructureObject')) {
    // got a StructureObject
    // $result->myFieldname()
    // $result->id: $autoid
    // $result->parent: Site|Page-Object hosting the Structure
}

```

---

<div class="post-metadata">

**Author:** ![lowtechlab](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@lowtechlab](https://forum.getkirby.com/u/lowtechlab)\
**Post date:** [September 24, 2026, 10:19am UTC](https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572/2 "2026-09-24T10:19:48Z")

</div>

Hello @bnomei

I’m inheriting an old kirby site (v 3.10) with your old autoid plugin.

I’d like to delete it because it’s not maintain anymore and uuid exists.

Could you help me and tell me how to replace in the code such line to avoid calling the autoid() function but instead using kirby’s native function?

`autoid('blog')->children()->listed()->sortBy('pubDate', 'desc');`

Thank you

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [September 24, 2026, 12:47pm UTC](https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572/3 "2026-09-24T12:47:27Z")

</div>

something like this? [Migration Autoid to Kirby UUIDs](https://forum.getkirby.com/t/migration-autoid-to-kirby-uuids/28212)

---

<div class="post-metadata">

**Author:** ![lowtechlab](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@lowtechlab](https://forum.getkirby.com/u/lowtechlab)\
**Post date:** [September 29, 2026, 7:04am UTC](https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572/4 "2026-09-29T07:04:40Z")

</div>

Thank you for pointing me this script.

Unfortunately, it’s not working as I’m explaining in the other thread.

Also, I beleive this script will replace autoid value in all content by uuuid value.

However, my question was more about the autoid() function. How to replace the usage of autoid() function?

I guess, i should replace

`autoid('blog')->children()->listed()->sortBy('pubDate', 'desc');`

by something like

`uuid('blog')->children()->listed()->sortBy('pubDate', 'desc');`

in the code but I didn’t find such uuid() function neither the equivalent to your autoid() function. Any idea?

---

<div class="post-metadata">

**Author:** ![bnomei](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bnomei/32/775_2.png) [@bnomei](https://forum.getkirby.com/u/bnomei)\
**Post date:** [September 29, 2026, 2:26pm UTC](https://forum.getkirby.com/t/kirby3-autoid-unique-id-for-pages-files-and-structures-to-create-safe-relations/23572/5 "2026-09-29T14:26:49Z")

</div>

> **[page()](https://getkirby.com/docs/reference/templates/helpers/page)**
>
> Fetches a single page by id or the current page when no id is specified
