One of the big benefits of using an existing system such as WordPress or Magento, is many things simply come out of the box.
One of these things is being “SEO – friendly”: being optimized for the search engines.
Note: While not all WordPress installations are perfect for SEO, it’s usually really good compared to custom installations.
When you’re working in ASP.NET MVC, chances are you’re dealing with a custom solution. That is great; it just means we have to do a lot of things on our own.
In this post I will go through the most important elements. However, SEO changes all the time and we don’t really know what triggers Google – so it’s worth continuing your research afterwards to find out if there are things that are forgotten.
I decided to split the changes into “Required”, “Important” and “Nice to have”. What category I placed them in is a bit random and based on my own experiences and what I’ve read – but use it more as a general guideline.
Required on-site SEO optimisations for ASP.NET sites
Make site is indexable
Note: If you Google “Angular SEO friendly” you will get plenty of methods on how to do this in practice.
Unique title tags for each view
One of the most important ranking factors is the <title> tag in the header. Make sure to set a unique one for each view in your application – also small pages such as contact and about.
For dynamic pages this is the most important, as you would often have your main content there.
Important on-site SEO optimisations for ASP.NET sites
Sitemap in ASP.NET MVC
Sitemaps are important to tell the search engines exactly what pages you have. Unfortunately you have to make them yourself.
For smaller sites, it’s quite simple. Either you do it manually (which works if you don’t have any dynamic content) or automatically (more on that in a second). You simply make a controller called Sitemap, and makes sure your site responds to calls such as /sitemap and /sitemap.xml .
For bigger sites it’s challenge. If you have a million pages which a previous customer of ours did, you need to run an underlying console job that generates the sitemap.
To help you build it there are a couple of Github projects to help you, and here is an example:
Only one <h1> on each page
Each page, when fully rendered, should only have a <h1> tag. The <h1> tag is what the page is about, and should be the main headline.
Canonical URL on pages
It’s in general a very good idea to put a canonical URL on most views. The idea is you tell Google what the real version of the URL is.
A typical example is you have the same page that gets indexed with unique query strings:
The idea is you then make a canonical URL and refer to itself. So if your view is placed on http://domain.com/page, and you have a version such as http://domain.com/page?ref=query, you should have a canonical URL that is http://domain.com/page.
Nice to have on-site SEO optimisations for ASP.NET sites
Remove /home/ from URL in ASP.NET MVC
In a lot of ASP.NET MVC projects, many pages end up having a /home/ url. An example could be /home/contact.
The shorter and more clear URLs, the better. And this is just a quick small thing to update inside the route file.
Prev and next on paginated listings
When you have a paginated result, it’s worth implementing the “prev” and “next”. It’s a way of telling the search engines you are on a paginated result, and what the next and previous pages are.