How to hide the Space Directory button for Anonymous users
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Please note that all the workaround stated on this page are beyond Atlassian Support Offerings.
Purpose
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:
<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:
<script>
AJS.toInit(function(){
if (AJS.params.remoteUser == ''){
AJS.$('#space-menu-link').hide();
AJS.$('#sidebar-spaces').hide();
}
});
</script>
Related guide: