The Most Legit Use of Namespaces

As a developer pointed out once, namespaces are meant to disambiguate two different pages that otherwise would have the same name (just like namespaces in some programming languages) :slight_smile:

If you think of them that way there are valid use cases like the ones I mentioned in this thread:

Instead to organize things hierarchically there are better alternatives and indented blocks is one of them. When it comes to pages, the concept of indexes that I described later in that thread is the best one to organize pages hierarchically, in my opinion :slight_smile:

2 Likes

thanks for the explanation.

I looked at the page you linked to, and boy there is some impressive stuff in there. I have no database background and am a Logseq newbie so a lot of the stuff discussed there is a bit beyond me.

We may see some interesting developments in Logseq yet.

1 Like

To add a practical example to Alex’s answer:

Namespaces are useful for keeping the same name apart if used in different contexts. Think about “apple”, which could be a fruit, a company etc.

So you can use a namespace “companies/apple”, “fruits/apple” to keep them separate.

A programming example would be if you have multiple functions named “print”, you could keep them apart by namespaces “std::print”, or “myLibrary::print”.

That doesn’t imply a taxonomy (a system for organizing things into different categories), it is just to keep the names apart. More details in my other answer above.

Unfortunately the two concepts get mixed up in Logseq, which causes a lot of confusion.

Thank you. I still have a lot to learn. I guess I won’t be confronted with the issue because I always try to use unique page names. To take the apple example, I would call 1 of the 2 pages Apple-company and the other Apple-fruit, so a search for apple would yield 2 results.

As for taxonomy, I am reading a non-fiction book and making notes with the built-in PDF viewer. I made a 1st page with some early notes that set the scene.

After that I make a page for each chapter or group of chapters that deals with a specific issue. In the page properties I have a property called parent, and I put a link to the parent there. In the parent properties I have a property called children where I have put a link to each of the children, all of which have their own unique name.

Being a newbie, I am not sure if this is a reply that is relevant to your comment. If it is not, I apologize.

1 Like

I’m still on the fence for one of my namespaces. I have notes for DnD (Dungeons & Dragons)
I had a very involved namespace for it, but made it a little bit more manageable by changing DnD/campaign name to DnD campaign name.
However for one campaign I ran I moved my Google docs to Logseq 1 to 1. There’s a lot of files and my hierarchy now looks like this:


And that’s just a fraction of the total amount.

This seems a legit use of namespaces as most of those pages won’t make sense in terms of their name on their own.

Anyone any thoughts on this? (Really enjoying these discussions on structure tbh!)

There are a couple of good reasons to use real namespaces instead of unique names

  • A namespace tells you what the namespace, and what the name is. Is Apple-fruit in namespace “fruit”, or is “Apple-fruit” some common name? What about “Mary-Jane”?
  • you can use search functionality to query namespaces (see also other answers from @Siferiax ), Logseq doesn’t know that “Apple-fruit” is a fruit.
  • one might be required to use certain names for compatibility with other users (e.g. courts use naming conventions like “Exhibit A”)
  • two people might have picked the same name, and you want to merge the graphs
  • print is a name of the function, and it wouldn’t be a good idea to rename it everywhere to print_std)
  • if you have a given taxonomy, you wouldn’t want to rename the individual groups to avoid conflicts with your own preexisting tags. E.g. you decide to classify animals. A housecat would be under
    Animalia > Chordata > Mammalia > Carnivora > Feliformia > Felidae> Felinae > Felis > F. catus. (I am using “>” to show that we are not talking about the namespace operator “/” in Logseq.
    But what if you already have a page “Felidae” (for the movie)?. You could rename “Felidae” into “Felidae-animal-kingdom”, but now you are not using the established naming scheme for animals, but your own. This will cause confusion. So instead, you create a page for each group in its own namespace AnimalTaxonomy/AnimaliaAnimalTaxonomy/F. catus. Then each page gets a property that tells which parents (one or more) it has.
  • If you use namespaces, you get some syntax checking when you enter the names. Otherwise it’s really easy to accidentally end up with lot’s of synonyms, like Apple-company, Apple-business, Apple-corporation, Apple-corp etc.
  • You can rename namespaces in bulk (still needs a script, but hopefully will eventually be part of a tag management UI)

That’s a good way to do it.

If you want to dig deep, look at these posts: Specify and display relations between pages/tags , Would a rich commitment to hierarchies and classification be an anathema to Logseq culture? , Knowledge Management for Tags / Tag Hierarchies

2 Likes

Thanks for your detailed reply. I’ll check out those posts.

Your points make a lot of sense but many/most are not applicable to me: I am a home user and the only one to use Logseq. But then again …… never say never :grinning:

1 Like

This makes me think: if Logseq will get templates of properties based on tags like Tana, namespaces could be used to chain templates like Tana’s inheritance between its supertags™. For example:

- Alice #person
  birthday::

- Bob #person/author
  birthday::
  books::

- Charlie #person/actor
  birthday::
  movies::
4 Likes

Looks like a good scheme to me.
These are the alternatives I could think of. Did I miss any?

  • Namespaces
    • lightweight, easy to search
    • interface of properties and namespaces could be tricky (e.g. if we also start to categorize games into a hierarchy)
  • Properties
    • ok for hierarchies, but would still need a namespace to keep all of the “Notes Session 1” pages
      separate
    • I don’t think it’s a good solution, like you said, it’s not really a taxonomy
  • Unique names like “Notes Session 1 DnD Asken”
    • not good…
  • Everything in one big page
    • might render slowly
    • interferes with normal indentation (but could use subheadings instead of indentation)
    • not as easy to navigate (but a search script might create a good index page)
  • Nested tags
    • don’t seem to be stable (I haven’t tried in a while)
    • easy to get wrong without typing
1 Like

Thanks for confirming namespaces are probably the best fit here!

Hah yeah, that would be a ridiculously big page. Not useful to navigate as you said.

You can do something like this with the powertag plugin.

I use namespace in only one scenario : months of a year. (I’m used to follow track of time with something similar to bullet journal methodology)

2023
2023/01-Jan
2023/02-Feb

Year’s page will contain events of the “future”. When a new month starts, I move the bullets on the newly created month’s page.

As said in this discussion, namespace helps to make 2 pages with “same name” unique.

With this convention, I can have monthly pages of a year nicely sorted at the bottom of page 2023.
I can also use the same naming convention for months of next year, as namespace guarantees unique page name (2023/01-Jan <> 2024/01-Jan).

3 Likes

Lol I do the exact same thing for the exact same reason! :smiley:
Though my year page only contains year related info (like a year theme) as I’ve never really been one to use a future log.

For your interest, if you edit the format for journal pages’ names to year/month/day, you will get journal pages under namespaces automatically :slight_smile:

8 Likes

This sounds great, where/how is this set?

Settings > Editor > Date format (the second dropdown)

1 Like

So, in the 2nd dropdown that would be option EEE, yyyy/MM/dd: correct?

I have only tested this one, I don’t know what happens with the others:

1 Like

This works extremely well.

I’ve started naming any date related pages similarly… E.g.,

2023/07/12/Meeting with Bob
2023/07/13/Agenda for morning meet
2023/07/13/Speech notes

Going to the 2023/07 page lists all my journal pages and everything else happening/that happened that month.

3 Likes

I started using Namespaces in Logseq when I began using the app back in February as a way to have an overview of all my topics/pages and I have created a common root namespace (I’ve seen others use a "/My/"), then create from there (ex: /my/projects/prjectx/client1/...). I’ve learned that Namespaces can be very lengthy, sometimes 10 level deep, and using such page names inline with your text is not usable so one must use the Markdown Link Syntax to have some shorter description (ex: Had a meeting with [John]( [[/my/projects/projectx/client1/Australia/John]] )), resulting in a text that is free of long namespaces and ugly formatting (“Had a meeting with John”) . Now the text looks ok and one can infer from other elements which “John” I am talking about (the rest of the description of my meeting with John, the time - I am probably having a single John during this time-, etc and, if not convinced, can hover the Logseq-Link and the popup will shed some light on the matter. It’s not that easy when you have to share notes with non-Logseq users though, but I won’t go into that rabbit hole here.

My relationship with namespaces has fallen a bit (even if I am still using them for the bird-view they offer) in favor of doing some simple tagging that, when combined in queries, gives the results I want. If I search for “cousin” and “Germany” I will get the information I need without having a Family Tree.

PS: I wish I could do quick queries in the CTRL+K - Search menu.

I also do some form of “shortening” the long namespaces and, even though I would create the following namespace: /my/financials/investments/company/Apple, in reality a tag like #Investments@Apple can convey the same amount of information in a much shorter way.

I believe I am quite far away from understanding how to correctly and productively use namespaces and sometimes I find I make a mess of everything but reading your answers here and elsewhere is insightful.

1 Like