How to hide labels in Confluence page using JavaScript in Specific Spaces

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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

This guide is for informational purposes and is not eligible for support from Atlassian.  If you have any questions about the information on this page, please reach out to our community at Atlassian Answers for help. 

Purpose

To hide labels displayed in Confluence page of specific spaces using JavaScript.

Solution

  1. Find out the space key for the spaces in interest by going to Space Tools > Overview. 
  2. Navigate to Confluence Admin >> Custom HTML
  3. Click Edit
  4. Add the following to At the end of the HEAD:

<script type="text/javascript">
    AJS.toInit(function(){
        if (AJS.$('meta[name=confluence-space-key]').attr("content")== '<space_key>'){
          AJS.$('#labels-section').hide();
        }
    });
</script>

(info) Replace the <space_key> above with the actual space key obtained from step 1

Last modified on Jan 3, 2025

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.