How do you get backlink references to show in the Siyuan App?

Hey Everyone,

I'm trying to recreate my logseq experience on Siyuan and I was wondering if you can ge the backlink references to automatically show up on the sidebar or in the page itself and I can also edit it inline?

Example:

image.png

    Welcome to here!

    Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.

    Signup About
    Please input reply content ...
    • dwinkl
      PRO

      Try adding

      AND type = 'p' (see documentation for advanced search - type filtering for additional parameters)

      If you want to select multiple types try

      AND type in ('p', 'h', 'd') for documents, headings and paragraphs

    • MiscReply
    • Latizes
      VIP Warrior Author

      Thanks for the tip, what would be the query to query all the blocks that's referenced to the page? In my picture it would be all the blocks or the references related to [[CTC News]]?

      Sorry I'm not too familair with SQL

    • dwinkl
      PRO

      The duplicates for me seem to be due to nested blocks. We can explicitly only select blocks if their parent is not already selected (this will give you the outer most block, you can flip parent_id and id in the second where clause to get the inner most blocks. In addition, I sepcifically exclude super blocks since they do not contain any content other than another block (I hope that is correct, @88250?) which will be included in the output already if it contains a link to the current page. Putting the following in the folder data/templates (within your SiYuan directory) e.g. as backlinks.md will create a template to insert a query for backlinks to the current document automatically:

      {{WITH cands AS (SELECT * FROM blocks WHERE markdown LIKE '%((.action{.id} %))%') SELECT * FROM cands WHERE parent_id NOT IN (SELECT id FROM cands) AND type != 's'}}
      
    • dwinkl
      PRO

      There is an icon that will open the backlinks panel when clicked: image.png

      For me it's in the lower right but not sure if I moved it. To query only backlinks to the current document (and not blocks within it) I have a template

      {{SELECT * FROM BLOCKS WHERE markdown like '%((.action{.id}%))%'}}
      
    • Visit all replies