Making a template where current page tags are listed and clickable

I just found the post for Making a template where all tags are listed and clickable. Wonderful!

Now, I’d like to achieve similar but have a clickable list of only those Tags in the frontmatter of the current page.

For example, using the Template in the above post, I get a nice clickable list of Tags.

  • I click a Tag, and it shows a Tag Search Page with all tagged Pages.
  • I click on a Page to view it.
  • Now, I would like to have a clickable link for each Tag on the current Page that would take me back to the previous Tag Search Page.

(Yes, I could just click the browser’s Back button, but I prefer keeping all navigation in-page.)

My use case is to develop a generic Template or Query that I could use anywhere on the site to provide a simple back-link to the Tags Search page(s) associated with only the Tags on that page.

Is this doable?

Thanks!

Adding page = @page.name could be a good start.

For example:

{{#each {tag select name where parent != "builtin" and page = @page.name order by name}}}
{{#let @tag_name = name}}
* [[📌 {{name}}|{{name}} ({{count({tag where name = @tag_name})}})]]
{{/let}}
{{/each}}

or

{{{tag select name where page = @page.name render [[Some Template]]}}}