Chapter 12. AngularJS and SEO

You might wonder why we are covering search engine optimization (SEO) in an AngularJS book. The answer is simple.

Currently, AngularJS and most JavaScript client-side frameworks are used mostly for web applications. Often, SEO is really not that important where web applications are concerned. As AngularJS gains in popularity, however, it could very well become a major player in the world of website design. AngularJS could potentially replace client-side code that is currently written in Java, PHP, Ruby, and Python.

That is not to say that those languages will be completely replaced—they won’t. Java, PHP, Ruby, and Python will continue to be as important as ever in the world of software development, but in a different way. Those languages and their associated frameworks will take on the role of providing the backend REST services needed for AngularJS and other JavaScript client-side frameworks. When you consider that complete websites could soon be written with AngularJS, it’s clear that SEO should then become a major concern for AngularJS developers. This chapter will help you to better understand AngularJS and SEO.

It is always best to focus more on building a great web application or website, and less on the specifics of search engines. Good design and performance are always by far the most important considerations for a new software project. Although search engine optimization is important, focusing too much on SEO during the design and implementation phase of a project can ultimately cost you valuable development hours.

Eventually, however, you do have to focus on getting your application or site found by all the major search engines. In this final chapter we will look at some of the ways to get your new AngularJS software found. Many of the practices presented here are recommended by Google.

Getting Found by Search Engines

With all that said, there are still some ways to increase your chances of getting a better ranking with Google and other search engines. We will cover the SEO tasks that are absolutely necessary:

  1. Sign up for a Google Webmaster Tools account, add your site to the account, and follow Google’s advice.
  2. Build a sitemap.xml file for your site.
  3. Add microformat tags to your site.
  4. Make sure your JavaScript is clean and easy for search engines to execute.
  5. Avoid calling REST services that take longer than two seconds to return results.