Add HTML code in confluence space homepage
- Writing by Rajveer
- On May 27th, 2008 at 3:20 am
In my previous article Starting with Confluence wiki I highlighted some of the key features and hurdles while working on Confluence Wiki. You can feel the endless fun to use Confluence especially when you are a general user. Where you just have to enjoy the fun part, easy to navigate, find, add, update and logoff.
It becomes really tough for someone like me who has to make changes in content area and display theme. One of the major issues I have come across so far is when I have to add some content in a new space (a space is known as a different section in Confluence Wiki) homepage. Problem started when I came to know that Confluence does not allow adding HTML code for a homepage content.
Confluence administrator panel defines the default content for a space home page. This content appears on the homepage of a new space which will be just added after defining this content in administrator panel. There is a text area provided to add that content but this text area does not work like a rich text editor, which means no HTML code. Means you can not do any formatting for your homepage content and you can’t put images also. This thing it is really funny, seems like they have missed a big point.
I decided to look for a trick to do the same by some other way. Initially I thought of doing this using JavaScript by replacing the ‘< >’ signs with ‘& l t; & g t;’ (please ignore the spaces between characters in single quotes). But still I was not convinced as the method sounds a little unnatural. So I started to look in to the code for s possibility and finally got lucky, check it out.
A simple and accurate trick
Before you start with this please note, if you are new with Confluence theme work please check my previous post where I have already explained that how to approach the target files to edit a theme. Please follow the steps -
Open the file page.vmd from your desired theme bundle and do a search for $body, you should be able to find it under a DIV tag. $body is a variable that dynamically displays the respective data under a page which is being browsed currently. So if you add anything extra (with or without HTML) with $body, that will be displayed in all the pages including homepage.
Luckily there is an additional variable to check the current page ID, $page.id. Do a check to deduct the your ID, write $page.id along with $body and then open the page in your browser. It should display a number there, that is your unique homepage ID. For me it displayed 589840 so I will use the same for an example. So now it seems possible to achieve our goal by using an if else condition there then show your homepage content only when the page id is verified as 589840, otherwise the default $body variable will work. Please check sample code below –
- #if($page.id == 589840)
- <h1>Welcome to my new space</h1> blah blah blah…
- #else
- $body
- #end
I believe this should resolve your problem, in case not please feel free to raise your queries in the comment area below.
- Previous post: Starting with Confluence wiki
- Next post: Great online CSS reference with live demos




Andy June 30th, 2008 at 10:10 pm
Your post has saved my me, I never imagined it could be that easier. In fact I was also doing some research using JavaScript incase some tricks can work out but I ended up achieving nothing but finally the 3 lines code from your post has done the needful, thank you. Keep writing the good stuff
Jedochardioda July 9th, 2008 at 8:14 am
tests time mashine
Guy Fraser August 17th, 2008 at 7:23 pm
There are some other ways to add HTML:
In the administration console, there’s a Custom HTML feature that lets you add your HTML on all pages – either in the section, just after or just before .
You can create User Macros (again via admin console) that can output HTML.
You can use the {html} or {html-include} macros, although they are considered a security risk if you don’t trust everyone who can use your wiki.
attismwegrers August 26th, 2008 at 9:00 pm
determination Dialect anenst despite beat
fornetti August 30th, 2008 at 2:55 pm
I do not believe this
Rajveer August 31st, 2008 at 9:07 pm
Fornetti – Could you please explain what you do not believe, can you share if you have a better way of doing it.
ME February 7th, 2009 at 5:48 am
good
reviews May 20th, 2009 at 6:50 pm
Hello. May I rent your layout for my site?
SouthWind19 October 23rd, 2009 at 3:20 am
I put to much thought in and over-wrote the whole thing. ,
html meta tags November 7th, 2009 at 6:38 am
I am very fortunate to have read your article. I learn a lot from it and I am waiting for
your next issue. Thanks.