How do I show/hide sidebar in the documentation theme depending on a URL parameter?

I have put together product documentation using the documentation theme and link to individual articles from different parts of the product. In some cases, I want the sidebar to be expanded and in other cases I want the sidebar to be hidden, depending on which page the article is linked from and how big the window will be.

The logical way to accomplish this would be to include some kind of flag to indicate whether the sidebar should be shown or hidden:


I couldn't see an obvious way to do this, so I was curious to see if this seemed feasible to anyone.

1 answer

1 accepted

0 vote
Davin Studer Community Champion Sep 25, 2013

You could do something like this. I would add it to the "At end of the BODY" section of the Custom HTML page in Confluence Admin.

<script type="text/javascript">
AJS.toInit(function () {
	var show = getParameterByName('show_sidebar');
	var splitPos = AJS.$('#splitter .vsplitbar').css('left')
	if((show === '1' && splitPos === '0px') || (show === '0' && splitPos != '0px')) {

function getParameterByName(name) {
	name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
	results = regex.exec(;
	return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

Davin Studer Community Champion Sep 26, 2013

Did this work for you?

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,921 views 27 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you