How to hide the Space Directory button for Anonymous users
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Please note that all the workaround stated on this page are beyond Atlassian Support Offerings.
The Space Directory provides a list of all the spaces in your Confluence site. If you need to disable the Space Directory for anonymous users, you may do so by using JavaScript as per highlighted below.
Solution
Navigate to Confluence Administration page >> Custom HTML.
Click Edit.
Add the following to At the end of the HEAD section and click Save:
1 2 3 4 5 6 7
<script> AJS.toInit(function(){ if (AJS.params.remoteUser == ''){ AJS.$('#space-menu-link').hide(); } }); </script>
You may also want to hide the Spaces list that is presented on the sidebar. If that is the case, just use the following script instead:
1
2
3
4
5
6
7
8
<script>
AJS.toInit(function(){
if (AJS.params.remoteUser == ''){
AJS.$('#space-menu-link').hide();
AJS.$('#sidebar-spaces').hide();
}
});
</script>
Related guide:
Was this helpful?