META Tags for Expression Engine Template/Index Pages

1st February, 2012 in Technical 1 Comment

I am quite new to Expression Engine, and although its quite flexible it does have it’s shortcomings.

One of the main issues I can see with it is its inability to manage META information. The in-built way would be to create a Channel Field for each Channel so when you publish data you can add in the META information and then display in in the template or header file. BUT if you have many channels, you need different names for each of these and it becomes a lot of fields to manage in conditional statements in the template. You cannot add fields to the main template index file either (e.g. a blog list).

I guess the above reasons is why so many forums online show data being embedded in the template files themselves. Well, although EE may be a great system, this is a massive NO NO for content managed websites. All information like this must be accessible in the CMS by the website owners who are likely not to have HTML experience.

So I installed SEO Lite (

This works very well on a per page basis (.e.g. an about us, or actual blog page). Because it adds the META fields to the entry for the page.

But this too will not allow an individual template index page to be managed. It seems these template index pages in EE are quite hard to add your own data to.
So I have combined Global Variables with SEO Lite and now have the perfect CMS managed META data.

The following code first checks is a page exists, e.g. blog/blog_post and take META info from there or use the default. If we are not on an individual page, but a template/index file which we don’t have data for (e.g. blog listing).

The second IF statement takes the segment name from the URL and prepends it to some text such as ‘_meta_title’. What this produces is a call to a global variable based on the segment name, e.g. ‘blog_meta_title’. All you need to do is then create the Global Variables based on the segment name.

The last IF statement is for the home page, and will get the META info you add in the Home page.

{if segment_2 != ''}
{exp:seo_lite use_last_segment="yes" friendly_segments="y" default_title='' default_keywords='' default_description='' }
{if segment_1 != '' &&  segment_2 == ''}
{exp:seo_lite use_last_segment="yes" friendly_segments="y" default_title='' default_keywords='' default_description='' }
{if segment_1 == '' &&  segment_2 == ''}
{exp:seo_lite url_title='home' default_keywords='' default_description='' }

Further work I would like to do is if the global variables do not exist, then to show the default SEO Lite content. 

Picture of Laurence Cope

Laurence Cope 8th June, 2012 at 22:39 pm

We have improved upon META tag management for listing pages... If you have a channel called Blog for example, the URL is /blog, then you dont actually have an entry for that index listing page. I do have a channel called Pages for things like About Us, Contact Us etc. So if you DID add a page called Blog, with URL /blog into this Pages channel, then you CAN use SEO Lite's META entries for this entry and then show these on the Blog page.

Leave a Reply