How do I remove the side bar in Confluence?
Problem
Rather than removing the sidebar, it's recommended to hide the sidebar (or collapse it). Confluence provides methods for hiding the sidebar, which we can trigger via JavaScript.
The following methods are provided as is, and without warranty. They are proof of concepts only, and should not be relied upon - they may fail in newer versions of Confluence. Each method will also collapse the sidebar, regardless of the user's preference to the width of the sidebar. These methods may be annoying for users who prefer to have the sidebar open.
The appropriate JavaScript snippet must be added to the custom HTML of your site, at the end of the HEAD section.
Solution
For sites using the default theme:
<script>
AJS.toInit(function(){
if (AJS.$("div.ia-fixed-sidebar").width() > 55){
AJS.Confluence.Sidebar.toggle();
}
});
</script>
For sites using the documentation theme:
<script>
AJS.toInit(function(){
AJS.$('#splitter-button').not('.collapsed').click();
});
</script>
Alternatives:
- Each user can collapse the sidebar individually, and their preference will be remembered (via a cookie)
- Use the Documentation Theme instead, and collapse the page tree individually
- Look into adding a Marketplace app such as Adaptavist's Builder Theme or HideElements for Confluence, which will allow you to customise your own theme layout. Note: these apps are created by third-party developers and not managed by Atlassian.