Collapse namespace prefixes

When creating new pages, in order to avoid conflicts, it’s useful to add a prefix. E.g. Book/Book Title.

In Roam, there is an option to collapse the prefix, so when we link it’s shown as [[B/Book Title]]. It would be nice to have this option in Logseq as well

Hi @andrea, I know that some people like namespaces, but I have trouble seeing their value. They seem to me to be a way to add a type of folder hierarchy to Logseq pages, but this can also be done with tags like #book and then a page for #book or a query. Is there a benefit over that method that I’m missing?

Also, does Logseq even support namespaces, or does it just allow the use of / in page titles?

1 Like

namespaces could be a nice addition imo.
It helps when you need different pages around the same master topic (same Title) that are automatically linked like : [[comic/Star Wars]] [[TV/Star Wars]] [[movies/Star Wars]] [[quotes/Star Wars]].

using tags like #book #movie doesn’t provide the same flexibility : once you have [[Star Wars]] you can’t create another page with the same title, and creating [[book-Star Wars]] doesn’t automatically create an unlinked-ref (afaik, unlinked refs are parsed from the content only, not from titles )

more details on namespaces, taken from :

namespaces to categorize/disambiguate

Namespaces are, and are simply created, by using a backslash / in the page title. In our examples we might end up with “Book/How To Take Smart Notes” and “Article/How To Take Smart Notes”

Semi-Automatic Namespace Collation

Typing [[Book/How To Take Smart Notes]] somewhere will:

  1. Create the page Book/How To Take Smart Notes
  2. If you go to the page [[Book]], the link, your mention of the page, will show up under Unlinked References.
  3. If you go to the page [[How To Take Smart Notes]], the link, your mention of the page, shows up there under Unlinked References as well.

Folders on Export

When doing an export to Markdown, the namespaces will become folders, and the last part of the namespace will be a regular file in that folder.

Clean Display Options

The initial default for displaying namespace links is to show the whole link.
Using the shortcut sequence CTRL C followed by CTRL L you can cycle through that option, abbreviated, or isolated:

  1. [[Book/How To Take Smart Notes]]
  2. [[B/How To Take Smart Notes]]
  3. [[How To Take Smart Notes]]

The color of the links will change according, so visually it is readily apparent 2 & 3 are namespace links

I like the clean display options (it could be somewhat possible with aliases), but most importantly, the Semi-Automatic Namespace Collation would be great .

I think if unlinked refs were also evaluating TITLES:, we could partially emulate namesspaces using nested pages, as [[[[book]] LOTR]] [[[[movie]] LOTR]] would appear as unlinked refs inside [[LOTR]]


I think @cannibalox covered most of the reasons. One last reason, I’d add is that it makes search faster.

I like to track Goals and progress. I create a page for each goal with a namespace Goal. The goal pages are empty, but I refer to them from the daily page. Even if I don’t exactly remember the name of the page, typing Goal/ restricts the search and makes it much easier to find the right page


backlinking the related topic with recent discussion :

Totally agree. I already use namespaces for organizing my notes when searching and differentiating notes of the same name, but proper support for them would be great.

+1 for this – one of the only features that I still miss from Roam.

Namespaces are helpful when searching for pages of a particular type. For example, if I need to create a link to a project, I can easily see all projects when searching for it. Same for Books, People, etc. Tags do not help when performing a page search when adding a link.

There are two ways to do namespaces, adding type:: book to every page that describes a book or adding it to the page title, like described here. The latter can be searched for, using:

{:title [:h2 "📚 Books Namespace"]
:query [:find (pull ?page [*])
:in $ ?ns
  [?page :block/name ?title]
  [(clojure.string/starts-with? ?title ?ns)] ]
 :inputs [ "book/" ]

It will find all pages called book/book title (not Book/book title!).

It’s not optimal, but it’s a start.

PS, welcome @egfrenzy!