Inspired Buddy

Add HTML code in confluence space homepage

  • Writing by Rajveer
  • On May 27th, 2008 at 3:20 am

Confluence WikiIn 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.


Possibly Related Writings

6 Responses

  1. 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 :-)

  2. Jedochardioda July 9th, 2008 at 8:14 am

    tests time mashine

  3. 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.

  4. attismwegrers August 26th, 2008 at 9:00 pm

    determination Dialect anenst despite beat

  5. fornetti August 30th, 2008 at 2:55 pm

    I do not believe this

  6. 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.

Leave a Reply

If this is your first comment on Inspired Buddy then your comment will be held for moderation. So please do not repost if your comment does not appear immediately. I will remove any inappropriate or irrelevant comments.

 

Latest writings

Does usability really matter to usabilitymatters.org
The Usabilitymatters.org is a non-profit organization who claims to impart usability awareness through interaction between designers and design-sensitive consumers. Although you can find some sensible...
Submit your idea on project 10 to the 100
There is an old say in India, “Nothing is free other than assistance”. So here is a chance for everyone of you :-). Google’s Project...
If Mahatma Gandhi kud hav communicated like today
This video from Telecom Italia really has a beautiful concept which gave me shivers. I love the way Mahatma Gandhi did the great work...
More articles »