I was doing my SEO for the site build using Zend Framework. The first obvious question that I have faced was "how do I add meta tags via Zend Framework?"
I was looking at some typical scenario like this:
- keywords - words that identify what the page is about, usually used in search engines
- description - a short description of the page
- author - the author's name and possibly email address
- robots - to allow or disallow indexing by robots
- copyright - the copyright date of the page
I found that apparently it is dead simple.
You can echo the headMeta placeholder in your layout
<?php echo $this->headMeta(); ?>
And use in every action:
$this->view->headMeta()->appendName('description', 'Zend Framework, meta tags, SEO');
$this->view->headMeta()->appendName('description', 'meta tags with Zend Framework tutorial');
or view like this:
<?php $this->headMeta()->appendName('description', 'meta tags with Zend Framework tutorial'); ?>
<?php $this->headMeta()->appendName(keywords, 'Zend Framework, meta tags, SEO'); ?>
That's it! A line or two will help you sort out your meta tags! You can hardcode the fields like in example above or use variables or eve write a script to scan you views for keywords and put the in a database so you variable will be populated from the database and there would be no need to take care about meta tags as your app will do it for you! It just demonstrates how flexible Zend Framework is.