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 (http://www.addonbakery.com/expressionengine-addons/seolite.html).
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} {if segment_1 != '' && segment_2 == ''} {exp:seo_lite use_last_segment="yes" friendly_segments="y" default_title='' default_keywords='' default_description='' } {/if} {if segment_1 == '' && segment_2 == ''} {exp:seo_lite url_title='home' default_keywords='' default_description='' } {/if}
Further work I would like to do is if the global variables do not exist, then to show the default SEO Lite content.
Recent
22nd November, 2017 in
Amity is pleased to announce it's sister web design company has launched in Newport. http://nettlofnewport.co.uk will design & build, host & support and digitally market websites for customers in and around Newport, South Wales, using Amity as the technical backend. Nettl will also offer design & print material for marketing & exhibitions.
Did you know that approximately 96% of people leave a website without taking the action the website owner would like them to complete? Whether it’s buying a product, signing up to a mailing list or requesting a callback, the vast majority of people visiting your site do not do it!
28th November, 2016 in Advice
When did you last check the speed of your website? According to Google’s guide for webmasters, a good eCommerce website should load fully in under 2 seconds...
If your business isn’t currently using social media, now is the time to consider why that is.
25th October, 2016 in Advice, Amity News
December is the perfect time to kick-start campaigns and refresh your marketing. Even if the nature of your business isn’t remotely festive, your customers will appreciate the goodwill of a seasonal offer to two, or simply a friendly ‘Merry Christmas’ message.
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.