The Lazy Mans Guide to Expression Engine SEO
Search Engine Optimisation is an important part of setting up a website for many webmasters. Out of the box ExpressionEngine does not make use of meta tags however it is it is extremely easy to have page-relevant meta tags by making use of the ability to set them using categories and tags.
Don't get me wrong, I do not generally worry about this sites Google ranking but by the same token I don’t want it to be impossible to find for other that may find what I have written useful. Google released a good guide to get anyone started with SEO that suggests pages should all have unique titles, descriptions and keywords. So thats what we will do.
Before we start I looked at how I should best go about this and fond an entry on the ExpressionEngine Blog about setting up custom fields to add a description and making use of the Tag Module. There is also a third-party extension and plugin combination that you can use to handle this at a cost; LG Better Meta. Neither method suited my needs as I did not want to be repeating myself adding descriptions to custom fields, slowing things down by adding unnecessary code or buy an overcomplicated module.
We really only want our page-specific meta tags to show up on our single-entry page, the homepage uses hardcoded meta tags so we only add our code to the single-entry template. Below is the code I am using to dynamically propagate meta descriptions and page titles:
{exp:weblog:entries limit=“1” rdf=“off” disable=“category_fields|member_data|pagination|trackbacks”}
<title>{title} — {weblog}</title>
<meta name=“keywords” content=”{categories backspace="1"}{category_name}, {/categories}” />
<meta name=“description” content=”{summary}” />
{/exp:weblog:entries}
Now let us have a look and see what is happening:
{exp:weblog:entries limit=“1” rdf=“off” disable=“category_fields|member_data|pagination|trackbacks”}
The Weblog Entries tag calls all the data for the article that is being displayed. We make sure only the one articles data is being displayed by limiting to the “1” article then improve our page load time by turning off trackback auto-discovery (RDF) and using the disable= parameter to turn off aspects of the tag that we are not using in order to improve performance.
<title>{title} — {weblog}</title>
This next line creates a page title that appears in search results and at the top of browser windows, in the format:
Your Article Title — Your Weblog Name
Note: I ultimately decided to drop the em dash and weblog name and just go with the title as my titles are relatively long.
<meta name=“keywords” content=”{categories backspace="1"}{category_name}, {/categories}” />
My blog uses categories and the category names are the same as the keywords I wanted to use to I simply display the categories separated by a comma as keywords. adding the backspace= parameter removes the comma from the last entry to keep things tidy.
<meta name=“description” content=”{summary}” />
The description I wanted to use was always going to be the same as my short one paragraph summery so simply output the article summary. The summary field has XHTML formatting enabled by default in EE so paragraph tags were being added to by meta data. To resolve this when you log in to EE click on the Admin tab and then the Weblog Administration link. Here we can edit our fields and set format type to: none, as you don’t want any automatic paragraph tags appearing in your meta tags.
{/exp:weblog:entries}
Lastly we close the Weblog Entries tag and were done, SEO friendly pages without the need to type anything you were not already entering for each article!
This article was posted on 8 May 2009 in Code, ExpressionEngine
That's the end of this article. I hope you found it useful. If you're enjoyed this article why don't you have a look around the archives, where you can find some more tutorials, tips and general ramblings.