Any way to get variables' value in custom commands?

Found custom commands setting in config.edn recently, want to use it to fetch in variables’ values, is it possible to do that?

 ;; Add your own commands to speedup.
 ;; E.g. [["js" "Javascript"]]
 :commands [ ]

For examples, I want to make a command called “wiki”, and when I type <wiki then press Enter, it will give me such an input :[Wikipedia]([page name here]. In short, I want to make a command that go straight to a web url using variables like current page name. I can’t use template macros because <%current page%> always attaches a [[]] in return which will break the search parameter.

So I tested patterns like advanced queries but it didn’t work. Just some imitative and intuitional trying like:

 ["wiki" [ ;; failed example, don't copy
          [:editor/input ?t]
          [?b :block/page ?p]
          [?p :block/name ?t]


  ["wiki" [ ;; failed example, don't copy
           [:block/page :block/name]

All trying failed in the end. Any ideas or precise information about whether this is doable? Thanks.

Can try the logseq-powerblocks-plugin and use the syntax <%CURRPAGENAME%>.

E.g. create a powerblock like the following:

- wiki #powerblocks  

@hkgnp Thanks for the work! It does help in a particular way.

I noticed two sentences in readme:
“Button templates can be used within a Logseq template if you prefer.”
" <%PB:time%> Inserts a powerblock in your template, e.g. “time”. This only works for buttons."

Does it mean I can use <%PB:name%> to call up custom PBtemplate in Logseq System template?
Or just use this in PB normal template because the expression bias?

As an alternative solution you can adapt the GitHub macro example I made at the end of this post:

Macros support <%current page%>


  • You can just place something like {{wikipedia}} in any page
  • You can set a custom command so that when you start tying /wiki it will print {{wikipedia}}
  • You can style it with Hiccup (basically HTML/CSS with a Clojure-like syntax)
  • Native i.e. no plugins needed


  • It works only in Logseq while other Markdown editors will just display {{wikipedia}}
  • If a Wikipedia URL is slightly different from your page name you won’t be able to manually adjust the link

Yes, this can only be used in powerblocks templates.

Anyway the main problem I see with this idea in general is that <%current page%> gives the title of the page with spaces, while Wikipedia uses _ instead of spaces in its URLs. So @Roby_Ho are you using page names like [[Foo_bar]] or am I missing something?

Nice try, and the idea about macros. But if could use <%current page%> then can actually use it in Logseq system template, which supports <%current page%> too.
The point is, <%current page%> always returns a string with a double square bracket [[ ]], this will be included in search parameter and make it wrong, need take time to manually carefully adjust it.

About the space, you can add [ ]( ) to avoid it.

E.g. a compromise, right now I use logseq-powerblocks-plugin by @hkgnp , create a powerblock template in a page, like this:

- wiki #powerblocks

For now it can be used by typing /insert powerblock, for more instinctively use I copy its button renderer to custom command in config.edn:

 [    ["wiki" "{{renderer :powerblocks_, wiki}}"]    ]

Now if you type /wiki anywhere then Enter, it will pop up a white “powerblock button”, then click it manually, it will return a link in format []() and it can handle the spaces correctly.

It’s a compromise way, still, expecting a native way to solve this.

1 Like

another option : use the Full House Templates plugin from stdword (marketplace or GitHub - stdword/logseq13-full-house-plugin: Logseq Templates you will really love ❤️). it’s very similar to the powerblocks workflow (it adds powerful features too – js methods) but you don’t need the button, just type <wiki

the template (with an optional iframe)

- wiki
  template:: wiki
  template-including-parent:: false
	- [``{ }`` - Wikipedia](``{ }``)
	  <iframe src="``{ }``" style="height: 400px"></iframe>


:commands [
  ["wiki" "{{renderer :template, wiki}}"]     

@cannibalox Wow, took a quick trying. This plugin is perfect! And thanks the intro for and iframe, that’s new to me, will take some time to make a little research though :rofl:

Update: But this will cause another problem. This plugin seems like can only clear anything in the original block to render. It means if I use it in a page property block, it will clear anything originally which is the page properties.
But this seems like a changeable config, I will write an issue to see what’s going on.

Update: Issue here Any way to render but keep the original block contents? · Issue #1 · stdword/logseq13-full-house-plugin · GitHub

If you turn on “autoParse” in the plugin settings, you can just type {{{wiki}}} and the link will appear.

It seems like it doesn’t parse if a block has any other content. If type anything before then parse it {{{id}}}, it will not work.

Please try the latest version (0.0.26-alpha).

It works now! Thanks for the work! And it works perfectly with custom command {{{ }}}.

1 Like

Hi, @cannibalox! Thanks for reference to my work :pray::heart:

Guys, I’ve made a showcase from this discussion. In case of anyone get here to setup wiki in Full House Templates plugin.