Render cleaner namespace page titles. Turns "ns 1/ns 1.1/etc/I am not an Orange" into "I am not an Orange"

I use namespaces a lot and on some pages I prefer that the title of the page is just the title after the namespace prefixes.

I use this on certain pages that I prefer to be a little neater.

For example, when you load a page such as:


This macro will (should!) render the page heading as:

To use/install:

In config.edn, add this macro:

 "<style onload='Function(this.innerHTML.slice(2, this.innerHTML.length - 2))()'>/*
 if (document.querySelector('h1').innerHTML.split('</span>').length == 1) {
     var cleanTitleStr = document.querySelector('h1').innerHTML.split('/').pop();
     document.querySelector('h1').innerHTML = cleanTitleStr;
 } else if (document.querySelector('h1').innerHTML.split('</span>').length > 1) {
     var iconSpanStr = document.querySelector('h1').innerHTML.split('</span>')[0];
     iconSpanStr += '</span>';
     var cleanTitleStr = document.querySelector('h1').innerHTML.split('</span>')[1].split('/').pop();
     cleanTitleStr = iconSpanStr + cleanTitleStr;
     document.querySelector('h1').innerHTML = cleanTitleStr;

In custom.css, add these styles:

[data-refs-self*=".hide-me" i].ls-block {
  display: none;

To use:

On any page that requires a namespace clean-up, just add this block anywhere on the page.

{{clean-title}} #.hide-me

How to remove the hidden block!?!?

Just open your markdown file in a normal text editor to remove the block.


I am not sure if you need dev mode enabled or custom.js allowed, all the macro does is load and execute javascript in place, I learnt the <style onload trick from:

GitHub - 71/logseq-snippets: Snippets I’m using with

I have this running on Windows with dev mode enabled. Let me know if you can run this without dev mode.


I’ll admit the ability to just load Javascript macros anywhere has opened up some interesting possibilities. I do hope that this method of js execution is not disabled in future releases of Logseq.

Thank you!! It is working with current version 0.6.1. Now my notes title looks cleaner. I also hope that this macro will work until logseq has its own workaround to hide the hierarchy in the page title.