Customising the Site Title

Want to customise your site title based on a given link to be a good Google citizen? Here is how to customise the title within a snippet.

Have you ever wanted to customise the site title based on a given link? I do all the time! You see, it is really important to Google to customise the title bars so that the text listed is as friendly as possible.

By default, you may have something like this ….

1<title>
2  {{ item.contents.first.title }}: {{ account.name }}
3</title>

Not bad. It will give the name of the site along with the title from the first content item. Unfortunately, this is not so good when you have a list of items, like in a store layout or a blog. You can use the case statement on the slug variable to customise the message you would like displayed.

 1<title>        
 2  {% case  slug %}
 3  {% when '/' %}
 4    Welcome to my great site!
 5  {% when '/store' %}
 6    Shop for widgets. Cheapest widgets online.
 7  {% when '/blog' %}
 8    Latest blog entries from the commander in chief.
 9  {% else %}
10    {{ item.contents.first.title }}: {{ account.name }}
11  {% endcase %}
12</title>

That’s more like it! Now if we go to our home page, store or blog I get nice customised title tags for each section and for all other links, I get the default title.

Not only will this boost your search engine rankings, it will help your customers find what they are after on your site much more easily.

by Craig Sullivan
launch.ly

19 Nov 2012