How can I query for all pages with a tag using datalog?

I’ve tried three different approaches I found online and none of them work. Here is my current attempt:

    :title [:h2 "Current Strategies"]
    :query [
           :find ?name
           [?p :page/name ?name]
           (page-tags ?p #{"strategies"})
    :view (fn [result]
            (for [page result]
                [:a {:href (str "#/page/" page)} (clojure.string/capitalize page)]

Thank you for your generosity in helping.

Should be either both ?p or both ?page (or both something else), otherwise they don’t match.


Thank you for pointing that out. It was an error I had introduced while editing. I have changed them so they are both ?p and it still does not work. I also edited it in the original code for clarity.

  • It works to me.
  • You should get more specific on what doesn’t work:
    • Do you receive any error message?
    • Could you provide any screenshot of a tagged page that is not returned?


It appears that it wasn’t working because I am assigning the tags using a template. Simply cutting and pasting the tags:: line in and out of the resulting document makes it work. So this looks like a templating bug. Thank you for steering me correctly. I’ll look around on the Internet for workarounds or submit a bug report.

Bug report submitted.

1 Like

Generally when you add a template on the first block of a page it will not convert the block properties (including tags::) into page properties. Simply editing the properties part also works. (Putting in an extra letter, going out of edit mode, back in a remove the letter)
It’s annoying though.