# Global page decorations in V2

**URL:** <https://community.silverbullet.md/t/global-page-decorations-in-v2/2185>\
**Category:** Troubleshooting\
**Created:** [April 17, 2025, 7:09am UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185 "2025-04-17T07:09:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marad](https://community.silverbullet.md/user_avatar/community.silverbullet.md/marad/32/1179_2.png) [@marad](https://community.silverbullet.md/u/marad)\
**Post date:** [April 17, 2025, 7:09am UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/1 "2025-04-17T07:09:07Z")

</div>

In V1 there was an option to configure page decorations based on page attributes globally (still present in the v2 docs: [Page Decorations](https://v2.silverbullet.md/Page%20Decorations)).

I’m thinking, how could we achieve the same effect with V2. Do you guys have any ideas?

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [April 17, 2025, 3:01pm UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/2 "2025-04-17T15:01:21Z")

</div>

Yes, my plan for this is to use Lua metatables. This already _kind of_ works, just not for the page decoration use case 😆 . It’s undocumented, but sharing here so you can try.

This is my test page:

````auto
```space-lua
local mt = {
  __index = function(self, attr)
    if attr == "pageDecoration" then
      return {
        prefix = "🎄 "
      }
    end
  end
}

index.defineTag {
  name = "tree",
  metatable = mt
}

```
#tree

Sup

${query[[from index.tag "tree" select {name=name, pageDecoration=_.pageDecoration}]]}

````

You’ll see that in the query result the `pageDecoration` attribute is dynamically injected. However, since all the uses of pageDecorations in the UI happen across plug boundaries, this ability of using metatables gets lost. I have to figure out how to work around that.

By the way, I also intend to add a `schema` attribute to that `defineTag` call with an (optional) JSON schema, which can then be used to bring back the v1 schema feature, which can validate frontmatter, be used for attribute completion etc.

---

<div class="post-metadata">

**Author:** ![marad](https://community.silverbullet.md/user_avatar/community.silverbullet.md/marad/32/1179_2.png) [@marad](https://community.silverbullet.md/u/marad)\
**Post date:** [April 22, 2025, 3:14pm UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/3 "2025-04-22T15:14:01Z")

</div>

I can’t seem to get it to work, so until it does, I’m just trying to create a set of functions that would update the page decoration “in place”.  
And my problem is… there is no good API for changing the frontmatter of the note (or I cannot find it).

I’ve noticed that the closest to what I want (actually almost exactly) is the `index.patchFrontmatter` function BUT… it doesn’t work properly for me.

When my frontmatter is:

```yaml
---
pageDecoration:
  prefix: "X"
---

```

and I do:

```lua
local page = space.readPage(myPage)
local updatedPage = index.patchFrontmatter(page, {
  { op="set-key", path = "pageDecoration", value = { prefix = "Y" }}
}
space.writePage(myPage, updatedPage)

```

it doesn’t remove the `prefix: X` so now my frontmatter looks like this:

```yaml
---
pageDecoration:
  prefix: "Y"
  prefix: "X"
---

```

I think that the implementation [here](https://github.com/silverbulletmd/silverbullet/blob/d7e8ab1ea50d24f68175960c6581f70244340251/plugs/index/api.ts#L190-L191) only supports changing a single line value, but I’m not sure (didn’t really look into it, as I’m not very fluent in TypeScript).

Is there any other API for actually changing the frontmatter of a file?

---

<div class="post-metadata">

**Author:** ![zef](https://community.silverbullet.md/user_avatar/community.silverbullet.md/zef/32/7_2.png) [@zef](https://community.silverbullet.md/u/zef)\
**Post date:** [April 22, 2025, 4:49pm UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/4 "2025-04-22T16:49:05Z")

</div>

This should be the one and it should work as you are using it. This is the feature I AI coded in this video: [https://youtu.be/hmSsFVPmHKA](https://youtu.be/hmSsFVPmHKA)

It looks like I have to add more edge cases to the test suite to handle this one too.

---

<div class="post-metadata">

**Author:** ![Mrton0121](https://community.silverbullet.md/user_avatar/community.silverbullet.md/mrton0121/32/980_2.png) [@Mrton0121](https://community.silverbullet.md/u/Mrton0121)\
**Post date:** [April 22, 2025, 9:32pm UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/5 "2025-04-22T21:32:45Z")

</div>

Hey! It’s kind of related here. I couldn’t come up with a way to remove the linked mentions from a page in V2 since the widgets are read-only. Is there any ideas for it?

---

<div class="post-metadata">

**Author:** ![thepaperpilot](https://community.silverbullet.md/user_avatar/community.silverbullet.md/thepaperpilot/32/1557_2.png) [@thepaperpilot](https://community.silverbullet.md/u/thepaperpilot)\
**Post date:** [November 6, 2025, 9:49pm UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/6 "2025-11-06T21:49:51Z")

</div>

Just wanted to piggyback on this and say I’m having the same issue! I want to make a widget that can add or remove items from a list in the front matter, but calling set-key on a existing list will append the list I gave to the existing list, even adding duplicate items. If we had ops for removing the key or adding or removing elements to lists, that would be wonderful.

---

<div class="post-metadata">

**Author:** ![cladv](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/c/4bbf92/32.png) [@cladv](https://community.silverbullet.md/u/cladv)\
**Post date:** [February 13, 2026, 12:32am UTC](https://community.silverbullet.md/t/global-page-decorations-in-v2/2185/7 "2026-02-13T00:32:43Z")

</div>

Hi. I wanted to reply to this one.

Please take a look on my `function updFrontmatterSection(path, value)` that I shared on your CBT post.

> [@Journaling Utilities](https://community.silverbullet.md/t/journaling-utilities/3526/3):
>
> ```auto
> function updFrontmatterSection(path, value)
> --path: Frontmatter "root" section name
> --value: Value: The section values. Can be an array/list/dictionary/nested array of arrays and so 
> 
> ```
