Embed page content in another page

apologies if this is an obvious question however how do you write a query to embed the contents of a page into another page?

also could you do this in a way that it is editable and updates on the original page . ie editable transclusion?

thanks and loving using silverbullet. its clear to see how much hard work has gone into making such detailed software seem so simple. great job

If you’re coming from Obsidian which uses ![[link]], its’ not quite as easy, but it is still possible to embed a page in another page. You can do this with a template block, with:

page: "[[]]"

You could also create a snippet template that looks like this:

---
tags: template
description: Embed a page inside another
hooks.snippet.slashCommand: embed
---

```template
page: "[[|^|]]"
` ` ` (the md here is getting broken, that should be an ending codeblock ```)

Then all you need to do is /embed and your cursor will drop to the right place and you can start typing. Note: You can’t embed portions or sections of a page, like you could in, e.g., Obsidian, with [[page#heading]].

There are ways of embedding just sections.
Have a look, for example, to this GitHub issue: Selective Include · Issue #338 · silverbulletmd/silverbullet · GitHub

1 Like

I did not know that! Thanks!

amazing thank you!!!
how can you include the embeded page name in the template? ive tried so many different ways but no luck.
is there a site to learn these functions?

FYI, my currently preferred way of embedding another page (as a whole) is this:

```template
{{[[link/to/page]]}}
```

In template language [[link/to/page]]] evaluates to the (verbatim) content of that page.

Why I like it? It’s relatively brief, and easy to extend, e.g. if you want to also add the page name as a header and link:

```template
# [[link/to/page]]
{{[[link/to/page]]}}
```

Using a page YAML body as suggested by @SONDLecT is legacy although it still works, although you should already see a warning suggesting you replace it with an Live Templates include block, and if you read the docs on that, you’ll see the suggestion to replace that with the the code I just listed :wink:

1 Like

This is definitely a neater approach. I think that autocomplete isn’t…autocompleting with {{[[link/to/page]]}}, but once that bug is squashed, it will definitely be the preferred method for me.

Yep:

As a follow up, on edge (so next release) completion should now be fixed.

2 Likes