Symfony basic SEO tips
Symfony | Technical | SEO | August 15, 2010
Search Engine Optimization (SEO) is very important, if a consistent stream of visitor traffic is desired for a web page. Remember that more visits to you web page means a higher conversion rate. To achieve this goal a series of factors should be taken into account as Google's PageRank.
In symfony projects there are a list of basic steps you can follow to get good SEO:
Keywords in the "title" tag
The title tag should always be utilized to identify the content of a document. Thus, authors should provide context-rich titles, e.g. if there is a page about introduction to SEO and SEM then the title tag should not be just "Introduction" because it does not provide much contextual background , instead it could be "Introduction to basic SEO and SEM".
With symfony this can be achieved as follow:
public function executeShow(sfWebRequest $request) { $this->getResponse()->setTitle($this->post->getTitle().' | Jonathan Nieto\'s Blog | jnieto.org'); }
Then, in the title tag should be something like:
Introduction to basic SEO and SEM | Jonathan Nieto's Blog | jnieto.org
Keywords in the Page URL
Thanks to the Routing framework in symfony, this task can be achieve easily. Just update the routing.yml file from the desired application:
post_show:
url: /article/:slug
param: { module: Post, action: show }
requirements: { slug: \w+ }
In the example "slug" will be replaced with post title modified for the url, obtaining a nice url:
http://jnieto.org/articles/introduction_to_basic_seo_and_sem
This url is very meaningful for search engines.
Keywords in the "meta" Description Tag
The text in this tag is not visible on the page itself, instead some search engines make use of it. This reason is enough to properly utilize it.
With symfony:
public function executeShow(sfWebRequest $request) { $this->getResponse()->addMeta('Description', $this->post->getDescription()); }
Then in the description tag, there will be a short paragraph describing the main content of the current web page.
There are also other on-page ranking factors to optimize as keywords in the heading tags, keyword proximity, and keyword prominence. However they are not symfony specific, and will be explained in detail in a future post.
To keep your symfony site in a good ranking position in the main search engines as Google, Bing and Yahoo, remember to take into account these basic SEO tips.
Actually, the best and recommended way to define metas (title, description and keywords) is to use slots in the views instead of setting them in the controller...