Advanced customizing

Changing the look and feel of Confluence, using themes and color schemes isn't always enough. If you want to go a bit further by changing the appearance of Confluence, or you want to add some extra functionality to the layout, these more advanced topics might interest you.

The default space content

Whenever you create a new space, the first page of that space always has the same content. As a Confluence Administrator, you can change this default space content to contain any other content you like.

To change the default content of a global space, perform the following steps:

  1. Browse to the Administration Console (Administration | Confluence Admin).
  2. Select Global Templates from the left-hand side menu.
  3. Under the section System Templates, click on the Edit link below the Default Space Content text.
  4. Create the content you want to appear on the home page of new spaces. You can also use variables within the content.
    • $spacekey: This will be replaced with the new space key.
    • $spacename: This will be replaced with the new space name.
  5. Click on Save to save the new default content.

To change the default content of a personal space, perform the following steps:

  1. Browse to the Administration Console (Administration | Confluence Admin).
  2. Select Global Templates from the left-hand side menu.
  3. Under the section System Templates, click on the Edit link below the Default Personal Space Content text.
  4. Create the content you want to appear on the home page of new spaces. You can also use variables within the content.
    • $userFullName: This will be replaced with the space owner's full name.
    • $userEmail: This will be replaced with the space owner's email address.
    • $userPersonalInfo: This will be replaced with the space owner's About me text, entered in the user profile.
  5. Click on Save to save the new default content.

Custom HTML

Confluence allows you to add some custom HTML to every page in Confluence. A very common use case for this is to add a Google Analytics tracker to Confluence.

There are three places where you can insert HTML, as shown in the next screenshot:

  • At end of the HEAD
  • At beginning of the BODY
  • At end of the BODY

Before adding any custom HTML to your Confluence pages, make sure it is valid. Adding incomplete or broken HTML can result in not being able to use Confluence anymore.

Custom HTML

To insert custom HTML, perform the following steps:

  1. Browse to the Administration Console (Administration | Confluence Admin).
  2. Select Custom HTML from the left-hand side menu.
  3. Click on the Edit button.
  4. Insert the HTML in the corresponding text area as shown in the preceding screenshot.
  5. Click on Save.

Custom stylesheets

Confluence gives us the possibility to add custom CSS files to Confluence and potentially change the complete look and feel. In order to apply CSS, you need adequate knowledge on working with and writing in CSS. Beginner tutorials are widely available on the Internet, for instance at W3Schools (http://www.w3schools.com/css/default.asp).

Custom CSSs can be added on the global and space levels, although the last one is disabled by default and should be turned on by a Confluence Administrator. Spaces with their own custom CSSs will ignore the global custom CSS.

Note

Keep in mind that Confluence HTML may change between versions and your CSS might stop working. Atlassian does not support custom CSS or any issues related to it. So, always check your custom CSS when moving to a newer version of Confluence and adjust the CSS as required.

To enable custom stylesheets for spaces, perform the following steps:

  1. Browse to the Administration Console (Administration | Confluence Admin).
  2. Select Security Configuration from the left-hand side menu.
  3. Click on Edit.
  4. Enable the checkbox in front of Custom Style Sheets for Spaces.
  5. Click on Save to save your changes.

To add a custom style sheet to Confluence, perform the following steps:

  1. Browse to the Administration Console (Administration | Confluence Admin).
  2. Select Style Sheet from the left-hand side menu.
  3. Click on Edit.
  4. Add your CSS.

    To demonstrate the power of changing the stylesheet enter the next example.

  5. Click on Save to save your changes.

Use the following example to get an understanding of what is possible with custom stylesheets:

body:not(.dashboard) #main { padding: 40px 80px 0px; font-size:120%; }
#title-heading { font-size: 200%; }

#breadcrumbs { display:none; }

.content-navigation {width: 300px; height: 30px; }
.content-navigation ul { display:none; }
.content-navigation:hover ul { display:block; }

The first block will change the padding of the main element so that there is more whitespace on the left and right of the content. It also resizes the text to 120 percent and the page title to 200 percent of its original size.

The second statement will remove the breadcrumbs above the page title.

The last section of the stylesheet will hide the page tools (Edit, Share, and Tools) unless someone hovers the location with their mouse.

This is how your page will look like with this custom stylesheet installed:

Custom stylesheets

As the preceding example showed, changing the CSS is a powerful way to alter the appearance of your Confluence. It does require some basic CSS and HTML skills though.

There is a tutorial available online to get you started with changing the CSS at https://confluence.atlassian.com/display/DOC/Basic+Styling+Tutorial.

Site layouts

Confluence is built on top of the open source library SiteMesh, a web page layout system. To further change the look and feel of Confluence, you can modify these decorator files. If you want to change the decorator files, you should familiarize yourself with Velocity. The user guide is available online at http://velocity.apache.org/engine/releases/velocity-1.4/user-guide.html.

The decorator files in Confluence are grouped in the following sections:

  • Site layouts: These layouts are used to define the layout around the content such as the header and footer.
  • Content layouts: These layouts control the appearance of content such as pages and blog posts. They do not change the way the pages themselves are displayed, but allow you to change the way the surrounding comments or attachments are displayed.
  • Export layouts: These layouts control the appearance of spaces and pages when they are exported to HTML. If you are using Confluence to generate a static website, for example, you will need to modify these layouts.

To edit a decorator file, perform the following steps:

  1. Browse to the Administration Console (Administration | Confluence Admin).
  2. Select Layouts from the left-hand side menu.
  3. Click on Create Custom to edit the default file.
  4. Make any changes.
  5. Click on Save to save the page.

Use View Default to view the default decorator file. If something goes wrong, you can use Reset Default to return to the original layout.

While editing the decorator files, there are a couple of Velocity macros that you can use to insert items like breadcrumbs or menus in your layout. The following are some of these macros; more are available online at https://confluence.atlassian.com/display/DOC/Working+With+Decorator+Macros.

Macro

Usage

#includePage (pageTitle)

Includes a confluence page with the specified title. If there are 2 or more pages with the same title across Confluence, this macro will use the page belonging to the space you are currently viewing.

#searchbox ()

Inserts a search box similar to the default search box in the top-right corner.

#dashboardlink ()

Inserts a link to the dashboard page.

These macros work reliably only when you're editing the main decorator. They may not work in other decorators; they will definitely not work in the normal Confluence editor.

Note

If you have changed the layout so extensively that some features aren't visible anymore, you can reset the layout by directly browsing to the following URL. Substitute the base URL and the appropriate .vmd file.

http://<confluence_url>/admin/resetdecorator.action?decoratorName=decorators/main.vmd

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.73.175