# What is the code for a page result similar to a 📌 tag search?

**URL:** https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303
**Category:** General
**Created:** [March 9, 2024, 2:58pm UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303 "2024-03-09T14:58:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![daydaya](https://community.silverbullet.md/user_avatar/community.silverbullet.md/daydaya/32/284_2.png) [@daydaya](https://community.silverbullet.md/u/daydaya)
#### Post date: [March 9, 2024, 2:58pm UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303/1 "2024-03-09T14:58:47Z")

</div>

I need to query all objects related to this project on the project page, which might include pages or paragraphs, etc. Currently,

I’m using the following method to query different objects:

```query
task where tags = "{{@page.name}}"
render [[Library/Core/Query/Task]]

```

```query
item where tags = "{{@page.name}}"
render [[Library/Core/Query/tags]]

```

```query
paragraph where tags = "{{@page.name}}"
render [[Library/Core/Query/tags]]

```

```query
page where tags = "{{@page.name}}"
render [[Library/Core/Query/Page]]

```

However, this approach seems clumsy as I have to manually search for all objects. I realized that what I need is a display similar to the 📌 tag search page that automatically shows all related results without displaying objects that were not found.

Since I’m not very proficient in English and coding, I mostly rely on translation software and ChatGPT for help. If someone is willing to provide some key information and ideas, I would be able to try solving my requirements myself. Thank you very much 🙏

---

<div class="post-metadata">

### Author: ![Pietzaahh](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@Pietzaahh](https://community.silverbullet.md/u/Pietzaahh)
#### Post date: [March 9, 2024, 4:22pm UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303/2 "2024-03-09T16:22:59Z")

</div>

The source code for that virtual page is here: [silverbullet/plugs/index/tag\_page.ts at 95ae722a5055b8063d6b40113207261d3ea77e10 · silverbulletmd/silverbullet · GitHub](https://github.com/silverbulletmd/silverbullet/blob/95ae722a5055b8063d6b40113207261d3ea77e10/plugs/index/tag_page.ts)

It’s basically what you’ve written out but each section is surrounded by #if blocks

---

<div class="post-metadata">

### Author: ![daydaya](https://community.silverbullet.md/user_avatar/community.silverbullet.md/daydaya/32/284_2.png) [@daydaya](https://community.silverbullet.md/u/daydaya)
#### Post date: [March 9, 2024, 7:00pm UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303/3 "2024-03-09T19:00:13Z")

</div>

Thank you very much! 😀  
with your tips and the help of ChatGPT, I have achieved what I need. My final code looks like this:

````auto
```template
{{#let @tasks = {task where tags = @page.name}}}
{{#if @tasks}}
{{#each @tasks}}
* [{{state}}] {{name}} [[{{ref}}]]  
{{/each}}
{{/if}}
{{/let}}

````

```auto

```

---

<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: [March 9, 2024, 10:12pm UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303/4 "2024-03-09T22:12:15Z")

</div>

You got ChatGPT to write SilverBullet template code? How did you prompt it?

---

<div class="post-metadata">

### Author: ![paletochen](https://community.silverbullet.md/letter_avatar_proxy/v4/letter/p/cdc98d/32.png) [@paletochen](https://community.silverbullet.md/u/paletochen)
#### Post date: [March 9, 2024, 10:28pm UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303/5 "2024-03-09T22:28:05Z")

</div>

I got a lot of code from Gemini 😉

---

<div class="post-metadata">

### Author: ![daydaya](https://community.silverbullet.md/user_avatar/community.silverbullet.md/daydaya/32/284_2.png) [@daydaya](https://community.silverbullet.md/u/daydaya)
#### Post date: [March 10, 2024, 9:57am UTC](https://community.silverbullet.md/t/what-is-the-code-for-a-page-result-similar-to-a-tag-search/303/6 "2024-03-10T09:57:34Z")

</div>

In fact, I don’t have a special prompt. 😂  
I just give these instructions and codes to AI as a reference:

1. [Template Language](https://silverbullet.md/Template%20Language)
2. tag\_page.ts code
3. Mentions Widget code
4. My query code

Then tell it that I need code like Linked Mentions Widget and tag\_page.ts that will only be displayed when the query has results.
