Collapse the list of 'Pages tagged with X' by default

Is there a way to hide the list of of pages which are tagged with a page property, ie the ‘Pages tagged with X’ list? I’m trying to set up course pages in Logseq for my uni notes. I have a page where all the courses are combined, let’s call it ‘All courses’. On that page, there is the list of "Pages tagged with “All courses”. Those would be the courses (pages): Test course 1, Test course 2. I want to collapse that list, because I can just use page references to create a list which I can access and manipulate more easily than that list of page properties (see screenshot).

I assume this can’t be done very easily, but I’m not the only person that has been asking for this feature.

See:

Try adding the following code into file custom.js:

const taggedpages = document.getElementsByClassName("page-tags");
const taggedpagesObserver = new MutationObserver(function onMutated(){
    Array.prototype.map.call(taggedpages, (div)=>{
        if (div.dataset.initialized) return

        const classList = div.querySelector(".content .initial").classList
        classList.remove("initial")
        classList.add("hidden")

        div.dataset.initialized = "true"
    })
});
taggedpagesObserver.observe(document.getElementById("app-container"), {
    childList: true, subtree: true
});

Thank you SO MUCH for this, it works! I hope others will find this useful as well. Solved! :blush:

PS. For those wondering where to add the js code, I quote one of your previous posts I found:

"Put the following code in file custom.js (create inside folder logseq if missing); mentioned in this post

…by which you mean that one should open the graph folder, navigate to “logseq” and create an empty text file, paste the code into the file and rename the file “custom.js”. When you open Logseq, allow the js to run. (I know 99% of people here know more about coding than I do).

1 Like