# Content files cleanup

**URL:** <https://forum.getkirby.com/t/content-files-cleanup/24172>\
**Category:** Questions\
**Tags:** v3\
**Created:** [December 6, 2021, 9:53pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172 "2021-12-06T21:53:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![marc22761](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@marc22761](https://forum.getkirby.com/u/marc22761)\
**Post date:** [December 6, 2021, 9:53pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/1 "2021-12-06T21:53:13Z")

</div>

I changed field names in my yaml file. The pagename.language.txt files in my content folder is adding the new fields in the end but not removing the old fields from the files. Is this as it should be?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 6, 2021, 9:56pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/2 "2021-12-06T21:56:55Z")

</div>

Yes, old fields are not removed automatically. But you can either clean them up programmatically, or you rename the old fields with search/replace in your IDE.

---

<div class="post-metadata">

**Author:** ![marc22761](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@marc22761](https://forum.getkirby.com/u/marc22761)\
**Post date:** [December 6, 2021, 10:36pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/3 "2021-12-06T22:36:30Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [December 6, 2021, 11:24pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/4 "2021-12-06T23:24:24Z")

</div>

with the site running locally, you if you open the offending page in the panel, then open the content file for that page in a code editor and remove all the content and save so that the file is empty, and then press save in then panel, it should write back the data to the file with the old fields and data ommitted.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 7, 2021, 6:55am UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/5 "2021-12-07T06:55:34Z")

</div>

There’s also a recipe about cleaning up programmatically:

> **[Cleaning up content files](https://getkirby.com/docs/cookbook/extensions/content-file-cleanup)**
>
> Remove unused fields from content files

---

<div class="post-metadata">

**Author:** ![marc22761](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@marc22761](https://forum.getkirby.com/u/marc22761)\
**Post date:** [December 7, 2021, 8:55am UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/6 "2021-12-07T08:55:21Z")

</div>

Nice. Exactly what i was looking for. Has been working perfectly.

---

<div class="post-metadata">

**Author:** ![momonu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/momonu/32/15264_2.png) [@momonu](https://forum.getkirby.com/u/momonu)\
**Post date:** [October 24, 2025, 8:52am UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/7 "2025-10-24T08:52:08Z")

</div>

Hi @texnixe , it seems this script doesn’t work in kirby 5 anymore. For me it deletes all content files. In the log it says:

`Storage for the page is immutable and cannot be updated. Make sure to use the last alteration of the object.`

Is there another or new approach to clean up unused fields?

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [October 24, 2025, 9:11am UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/8 "2025-10-24T09:11:36Z")

</div>

You could use the Kirby CLI tool for this. It contains a clean:content command.

> **[GitHub - getkirby/cli: Kirby Command Line Interface](https://github.com/getkirby/cli)**
>
> Kirby Command Line Interface

---

<div class="post-metadata">

**Author:** ![momonu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/momonu/32/15264_2.png) [@momonu](https://forum.getkirby.com/u/momonu)\
**Post date:** [October 26, 2025, 12:44pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/9 "2025-10-26T12:44:17Z")

</div>

Thanks! This works … somewhat 🙂

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [October 26, 2025, 2:13pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/10 "2025-10-26T14:13:39Z")

</div>

Great… was there something it ididnt do?

---

<div class="post-metadata">

**Author:** ![momonu](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/momonu/32/15264_2.png) [@momonu](https://forum.getkirby.com/u/momonu)\
**Post date:** [October 26, 2025, 6:57pm UTC](https://forum.getkirby.com/t/content-files-cleanup/24172/11 "2025-10-26T18:57:43Z")

</div>

I created an issue for it: [Clean content command removes field values from fields defined in plugins · Issue #94 · getkirby/cli · GitHub](https://github.com/getkirby/cli/issues/94)
