Structure your wiki with templates

Following on from my previous post on how you can use labels to add some consistency to your wiki and help with user adoption, another great way to help make those first edits less daunting than staring at a blank wiki page is to use templates .

Templates in Confluence can be used for anything you can think of that might benefit from a uniform structure:

  • Meeting Notes
  • Server Inventory
  • Interview Record Sheet
  • ITIL Documents
  • Service Catalogue
  • Event Planning Checklist
  • etc.

and can be implemented at the Global level so they are available in every Space in a Confluence installation, or at a Space level so they are only available for pages in a particular Space.

To implement templates at a Space level:

1. Log in to Confluence as a user with Space Administration privileges and navigate to the Space in which you would like to create the template.

2. Select Browse -> Advanced and select Templates from the left hand menu

Templates Menu

3. Select Add New Space Template

4. Enter a meaningful Name and Description for your template and enter your template using wiki markup, e.g.

Name: Meeting Notes
Description: Meeting Notes Template
Template:
h3. Date - (Provide Date of Meeting)

h3. Attendees
* Michael Jordan
* Scottie Pippen
* Dennis Rodman
* Ron Harper
* Luc Longely

h3. Agenda
----
h4. Completed Last Week
*
*
*
...

h4. Working on This Week
*
*
*
...

h4. Blockers
*
*
*
...

5. Click Preview to see what your template will look like and refine the wiki markup in preview mode until you are happy with the template.

Templates Preview

6. Once you have finished editing your template click Save.

End users can now use the template in the Space in which it was created by either selecting Add -> Page from template from the Add menu in the Space:

Add Page from Template

or by selecting Add Page from the Dashboard and selecting the Space and Template they wish to use:

Add Page

The nice thing about pages created from templates in Confluence is they are not hard linked to the template so if you need to add, remove or change anything when you edit the page you can, e.g.:

Page from Template

Creating a Global Template so that it is available in all Spaces in a Confluence installation is pretty much the same process except you need to:

1. Log in as a user with Global Administration privileges.

2. Select Browse -> Confluence Admin

3. Select Global Templates from the left hand Configuration menu:

Global Templates

The remainder of the steps and then actually using the Global template are the same as above for Space templates.

As you may have noticed from the above screenshot you can also Import Templates that other people have created and made available on the Atlassian Puglin Exchange. Some of the provided templates on the Plugin Exchange include template bundles for Software Development and Human Resources.

I hope you found this useful as an introduction to templates, check out the Atlassian website for more information on Confluence Wiki Markup and Working with Templates.

Seed your wiki with labels

Labelling and tagging content in wikis is a great way of categorising content to make it easier to find, but sometimes people might need a bit of a nudge to label their content and you may find that people are not using the same labels for the same content, e.g. person A uses “user_adoption”, person B uses “useradoption”, person C uses “user-adoption”, etc. One way of making it easier for people to label content and encouraging people to use standard labels is to “seed” your wiki with the labels you would like people to use so that they appear in auto-complete as soon as a someone starts typing.

To “seed” labels in Confluence:

1. Log in to Confluence and navigate to the Space you would like to “seed”
2. Create a new page called “_labels” and save the page
3. Click the pencil icon to add labels to the page
Edit Labels Screenshot
4. Add add as many labels as you wish – more labels can be added later
List of Labels
5. Select Browse -> Pages and expand the Tree View of the Space
Pages Tree View

6. Click and drag the “_labels” page above the root of your Space
Move LabelsNow whenever someone adds or edits a page in that Space and adds labels, as soon as they starting typing in the labels dialogue box the auto-complete will match the labels added to the “_labels” page.
Labels dialogue box
Prefixing the page with an underscore (_) is a naming convention that I use to indicate that the page is not “real” content and by moving the page above the root of the Space in the Space hierarchy it stops the page appearing as a child page and cluttering actual content in the Space.

Seeding labels is obviously not bulletproof as it doesn’t force people to add standard labels to their content, but it’s a start and should help with guiding people to use the labels that you would like them to use for certain types of content.

Hope you find this useful and if you have any other hints or tips on encouraging people to label their content I’d love to hear them.

Confluence and MySQL

Over at Atlassian Answers I’ve noticed a few people reporting problems installing Confluence with MySQL and being told to use Postgres instead, but using a different database is not always an option and in my experience Confluence does work perfectly well with MySQL. I needed to complete another install of Confluence with MySQL recently and these are the steps that I used. I hope people find them useful.

Configure the MySQL Server
It’s recommended to use UTF8 character encoding for the database and this can be set in my.cnf (Linux) or my.ini (Windows) with the following settings under the [mysqld] section:

[mysqld]
...
character-set-server=utf8
collation-server=utf8_bin
...

For older versions of MySQL the default storage engine is MyISAM, but this can lead to data corruption as it is not a transactional storage engine and it is recommended that you use the transactional InnoDB storage engine instead. Again this can be set in the [mysqld] section of my.cnf or my.ini with the following:

[mysqld]
...
default-storage-engine=INNODB
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
...

Finally in my.cnf or my.ini you need to increase max_allowed_packets to at least 32MB with the following setting:

[mysqld]
...
max_allowed_packet=32M
...

After making these changes to my.cnf or my.ini save the file and restart the MySQL server.

Create the MySQL Database
Log in to MySQL and run the following SQL statement:

mysql> CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)

Check Character Encoding
Check that the database you have created is using the correct character encoding by running the following SQL statements:

mysql> use confluence;
Database changed
mysql> status;

and you should see the following information listing all the characterset settings as utf8:

Connection id:		23
Current database:	confluence
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		5.5.18-log MySQL Community Server (GPL)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8
Db     characterset:	utf8
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/tmp/mysql.sock
Uptime:			12 min 5 sec

Create the Database User
Create the database user that Confluence will use to access the database with the following SQL statements:

mysql> GRANT ALL PRIVILEGES ON confluence.* to confluenceuser@'localhost' identified by '<your password>';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

where <your password> is the password that you wish to use.

Configure Confluence to use MySQL
The following assumes you have already installed Confluence using the standard installation instructions and have started Confluence.

After entering your License key select Production Installation and that the External Database will be MySQL:

MySQL Database Selection
Next, select Direct JDBC Connection to connect directly to the database:

Direct JDBC Connection

Enter the connection details:

JDBC URL: jdbc:mysql://<hostname>:<port>/<database>?autoReconnect=true&useUnicode=true&characterEncoding=utf8&sessionVariables=storage_engine%3DInnoDB
Username: confluenceuser
Password: <your password>

where  <hostname>, <port>, <database> and <your password> are the values for your environment, e.g.:

jdbc:mysql://localhost:3306/confluence?autoReconnect=true&useUnicode=true&characterEncoding=utf8&sessionVariables=storage_engine%3DInnoDB

If all of the information is correct Confluence will connect to your database, create the necessary database tables and you will be presented with the following screen and can select Example Site to start using Confluence:

Connection Success

If you get an error message similar to the following:

Connection Error

the most common causes are:

  • Incorrect username/password
  • Incorrect database name
  • Incorrect port for the database
  • Incorrect hostname for the database
  • Network/firewall issue between Confluence and MySQL
To check the username and password log in to MySQL directly from the command line with:
mysql -u <username> -p
where <username> is the user you created for the Confluence database and enter your password when prompted. If you logged in successfully, check that you can access the database with the following SQL statement:
mysql> use confluence;
Database changed

If you cannot access MySQL with the username or password or can log in, but cannot access the Confluence database, connect as the root user:

mysql -u root -p

and check the username with:

mysql> select user, host from user;
+----------------+------------------------------------+
| user           | host                               |
+----------------+------------------------------------+
| root           | 127.0.0.1                          |
| root           | ::1                                |
| confluenceuser | localhost                          |
...

to make sure there are no typos in the username or host and check the database with:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| confluence         |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

to check that there are no typos in your database name. If there are typos in the username, password or database then try dropping the user and/or database with:

mysql> drop database confluence;
Query OK, 0 rows affected (0.06 sec)
mysql> drop user confluenceuser@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

and recreating them..

If the username, password and database are all OK, double check my.cnf for the port MySQL is running on:

# The MySQL server
[mysqld]
port            = 3306

and that this is the same <port> you are using in the JDBC URL that the Confluence setup wizard asks for. If the port is correct, double check the value you provided for the <host> in the JDBC URL, which may be “localhost” or “127.0.0.1″ if MySQL is running on the same machine that Confluence is running on. If Confluence and MySQL are running on the same machine and everything is correct, but you still cannot connect it may be that “127.0.0.1″ resolves to “localhost.localdomain” in your environment. To overcome this you can create a MySQL user to match any domain starting with “localhost” with the following SQL statement:

mysql> GRANT ALL PRIVILEGES ON confluence.* to 'confluenceuser'@'localhost%' identified by '<the password>';
mysql> FLUSH PRIVILEGES;

If Confluence and MySQL are running on separate machines then it may be that there is a networking or firewall issue between your Confluence server and your MySQL server. To check connectivity run the following command from the command line on your Confluence server:

telnet <mysql host> <port>

e.g.

telnet mysql.example.com 3306

and you should see:

Connected to mysql.example.com.
Escape character is '^]'.

If you get an error message or the command line hangs then there is a connectivity problem between your Confluence server and your MySQL server and you will need to ask your network administrator for help in rectifying this problem. Once your network administrator has confirmed that traffic is allowed between your Confluence server and your MySQL server try connecting Confluence to MySQL again.

That should be it :)

The instructions in this blog post were pulled together from the following resources:

I hope this post is useful to anyone who is having problems running Confluence with MySQL and if anyone is still having problems, or has any other tips or resources, please drop me a line via the comments.