SEO Tips For Symfony

Not all apps with Symfony are some CRUD backend that will be only used for logged in users. And sometimes, WordPress is just an overkill for a couple of pages that will be used for a marketing website. In those cases, you still want to keep using Symfony and you definitely want to optimize for your search engine. Also, wordpress and most existing cms are just a pain for users and developers, if you find more disadvantages for using them (for your use case), just don’t. Everyone will love you.

Which bundle should I install?

In my opinion, you don’t even need a bundle here. I think it’s fine to roll out your own code instead of adding one more dependency by installing a new bundle. Why?

  • It’s quite straightforward to write something that fits exactly your needs. Maintaining a couple of lines of codes makes more sense here than adding a big bundle dependency that does way too much than what you need
  • I don’t think there is a good enough bundle that could be easily extended, at least in the time that I had to search (if you know any please write a comment)
  • Think about your case and what works for your team (I know this doesn’t answer the question, but sometimes you have to do the search by yourself.)

Basic SEO without a bundle

In case you wanted to add google analytics tracking code, the easiest way would be to create a template for google analytics tracking code and include that template in your base layout.
If you want to modify some basic SEO meta tags, here is a sample code snippet that I have used in one of my projects that’s easy to extend and modify.

Here is an example on how to use it

In case you wanted a sitemap, here is an article that helps you get a sitemap up and running.


Hopefully I have demonstrated that having some basic SEO with Symfony isn’t complicated. If you have any better ideas or you do things differently, please share them in the comments below.