Hide header elements for anonymous users?

Maja Kovats February 25, 2019

I'd like to remove these elements from the Confluence header for anonymous/unregistered users:

menu 1.png

menu 2.png

"Log in" can stay.

I've looked at these resources, but I'm still unable to identify exactly what these elements are:

I know how to remove the entire header, but I'm hoping I can avoid that for this reason:

https://community.atlassian.com/t5/Confluence-questions/How-to-modify-the-breadcrumb-navigation-bar-for-Confluence-from/qaq-p/1016421

Sorry if this question is lazy and/or bad practice. If anyone can recommend an app to accomplish this, please let me know too.

Feel free to tell me I'm barking up the wrong tree entirely.

Thanks!

2 answers

1 accepted

1 vote
Answer accepted
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 1, 2019

Hello Maja,

Thank you for providing details into what elements of Confluence you’re wanting to hide.

I tested out a few CSS options and found the following works when applied as a global stylesheet to Confluence. This example would apply to all users.

#main-header-placeholder {display:none;}
#header-precursor {display:none;}
#header {display:hidden !important;height:40px; }
div.aui-header-primary {display:none !important; }
div.aui-header-secondary .aui-nav #search-ui {display:none }
#main-header {display:none;top:0px;left:0px; }
#metadata-history-dialog-link { display:none; }

However, when I attempted to apply this via Custom HTML with Javascript, it did not come out as desired. The top bar shrunk and I was unable to adjust its size via javascript alone. Here is the Javascript I used;

<script>
AJS.toInit(function(){
if (AJS.params.remoteUser == ''){
AJS.$('div.aui-header-primary').hide();
AJS.$('div.aui-header-secondary .aui-nav #search-ui').hide();
AJS.$('#header').setAttribute("style","height:40px");
}
});
</script>

While this is not a complete solution, you do have an option of using the CSS stylesheet or finishing the javascript portion to have it adjust the size of the header bar.

I hope this proves helpful and gives some direction on hiding elements from anonymous users.

Regards,
Stephen Sifers

Maja Kovats March 1, 2019

Hi Stephen-- thank you so much for putting this together. I have not yet tried it, but I'm sure its a great starting point.

In the meantime, I have also been looking into theme add-ons, and I've found it frustrating how while most allow different themes for different spaces - I've not found one that allows you to maintain the default Confluence theme for some spaces, while applying a custom theme to others.

I'm not responsible for all of my team's internal documentation and project spaces, just our customer-facing spaces (KBs). The default Confluence theme is perfectly fine and what people are used to internally, so there is no need to change it.

All I need is the ability to tweak the Confluence theme to be more appropriate for anonymous viewers.

Anywho, I just wonder if I'm missing something or going about this in completely the wrong way-- because this use case does not seem so uncommon to me.

Thanks again though!

Like Zak Laughton likes this
1 vote
Neetam Limbu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 1, 2019

Please click the settings icon on the top right corner, from the drop down menu, click on general configuration. Find the section "Look and Feel" and click Cusom HTML. Click on edit button and paste the following code on the head section and save.

<script>
AJS.toInit(function(){
if (AJS.params.remoteUser == ''){
AJS.$("#space-tools-menu-trigger").hide();
AJS.$(".aui-header-logo-device").hide();
AJS.$("#space-menu-link").hide();
AJS.$(".aui-buttons").hide();
AJS.$("#search-ui").hide();
AJS.$("#action-menu-link").hide();
}
});
</script>

Cameron Clancy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 10, 2022

@Neetam Limbu is this still working for you?  And is it Cloud or Server you're using?

It seems the "Custom HTML" option is no longer available??

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events