For search engine optimization there is a handy way to use the built-in Page Properties macro to define SEO data and output it in a template.
This recipe describes how to do that.
Create Page Properties on a Page
Edit the page and create a page properties macro and create the SEO properties (checkout the official documentation for more info how to create properties).
Add the Content Properties
In your custom template (Creating a Template) access the page properties with the $pageProperty placeholder like this:
: <title>$pageProperty.from("seo.pagetitle")</title> <meta name="description" content="$pageProperty.from("seo.description")"> :
If you are using the default WebHelp theme, you can add SEO to it with the steps below:
- Download the source of the WebHelp theme from our Bitbucket:
- Unzip the archive, navigate to /src/main/resources/com/k15t/scroll/scroll-webhelp-theme/scroll-html/include
- Open include-htmlhead.vm with a text editor and add the code above
- Save the file
- Continue from "Installing the new Plugin" section on the page: Creating a Template
- Upload the template to Confluence as a regular add-on
Pro Tipp: Hide Page Properties
By default the page properties will be visible to everyone, usually you want to avoid that.
To do so:
Let the page properties macro hide the properties, which will hide the page properties. Drawback of this approach is that you can only see the properties in the Confluence editor.