SEO: Entry Titles and <title>
An ever-present part of building any public website is Search Engine Optimization. We’re often asked, “Is ExpressionEngine SEO friendly?” - the answer here is: “it sure is, if you make it so!”
While ExpressionEngine goes a long way with its URLs being human-readable and search engine friendly, there are some other tricks that one can utilize to help this along. Remember, we control the templates, and therefore, we control what information is output and where.
One of those tricks is having a semantic <title> element for each page. So, how do we make that title element more useful, both to our readers and to search engines?
In ExpressionEngine, there are many ways to handle this. One of them happens to be the excellent Title Plugin by Lodewijk.
However, you can also do this entirely out-of-the-box with ExpressionEngine. How? It is all part of the basic mechanisms as described in The Importance of Semantics. ExpressionEngine knows what type of page you’re on, so why not leverage that - not just for your content - but for your titles as well?
Let us say that we want to show, using the same template, the title of the weblog, as well as the title of the entry; however, there is a caveat - the title of the entry is only appropriate for the <title> element when viewing a single-entry page.
Create a blank template in your site template group, and call it title. Put this in it:
<title>
{exp:weblog:entries weblog="default_site" limit="1" disable="trackbacks|pagination|member_data|custom_fields|category_fields|categories" rdf="off"}
{if segment_3 != ""}{title} - {/if}{weblog}
{/exp:weblog:entries}
</title>
What is going on here, then, you ask? First, we have a Weblog Entries tag - we need this because we want to show the title of the entry. Remember, we’re using one template for two purposes here: a single-entry page, and a multi-entry page.
However, we do not want the latest title and a hyphen to show up if we’re not viewing a specific entry. We know (from reading The Importance of Semantics) that Segment 3 will contain an entry’s URL Title when viewing a single-entry page. So, by using conditionals, we can test to see if Segment 3 is not empty and show our entry title if Segment 3 is, indeed, not empty; the snippet below, taken from our code-block above, performs that magic:
{if segment_3 != ""}{title} - {/if}
But we always want the weblog name to appear; to achieve that, we place the weblog variable outside of the conditional.
So, try that out. Create a test entry in your default_site weblog. Now, visit your site/title template without the URL Title - you’ll see simply the weblog name. Append your URL title, and you’ll see your entry’s title, a hyphen, and the weblog name.
Pretty spiffy, isn’t it? This can be applied in many ways, including category titles, and pagination.
You will note the use of the disable= parameter above. It is always important to optimize your templates. We can make processing this tag considerably easier by telling the Weblog Entries tag specifically that we don’t need certain information. That parameter will need modification when using this method on a category or pagination template.
Search Engine Optimization is an interesting business. In future articles we’ll explore other ways to make your ExpressionEngine templates even more search engine friendly.


