Follow me on twitter @yodasmydad
Ahhhh #Fringe can't finish like that!! Latest Tweet:

Hey I'm Lee. My blog was put up to house my strange thoughts, ramblings, nuggets of information I can refer back to and document my learning curves on new dev stuff like Umbraco v5 and other .NET related things.

All thoughts and comments on here are my own, and in no way reflect my employer - I also take no responsibility for spelling, grammar or terminology, so read at your own risk!

Blogs I Read

Sites I Like

Couple Of NopCommerce SEO Tips

I have been using a nopCommerce for about 2 years now, and have to say once you get your head round its architecture its actually a really great application (If a little long winded at times).  I haven't played with v2.0 properly yet, but just from having a quick look it seems awesome and I can't wait to have a play with it.

Recently I added a couple of little enhancements to a store which should make quite a bit of difference to a large store, nothing ground breaking about them but will help if you are carrying out an SEO campaign.

Page Load Speed

If you have a large Nop store with a lot of products in each category and have a lot of product filters (Specifications), you will see that it can be sluggish and not only is this not good for users but its also no good for Google.  As you may or may not know, page load speed is now part of their ranking algorithm (If you login to your webmaster tools account they even have a section in there on your page load speed).

So I have been looking at ways of speeding up the categories (And home page) and I always came back to the good old OutputCache technique.  This works fine for the home page, and I have put this in my home page which caches it for 1 hour at a time - and as you would expect the page load difference is now about 10x as fast.

<%@ outputcache duration="600" varybyparam="none" %>

But the main problem was always the category listing pages, these were always the slowest and after the home page the most visited sections (And usually the pages you want to rank)  - But if you have loads of filters and products in a category it can have A LOT of different querystrings.  After some fiddling around and Google'ing I came up with a custom way of caching these pages.  All it does is caches the RAW page url as a string and uses a custom method in the Global.asax to pass it to the output cache, its easy to do:

Add the following at the top of your category template (I added mine to the top of the ProductsInLines1.ascx)

<%@ outputcache duration="600" varybyparam="none" varybycustom="RawURL" %>

Now open up your Global.asax file and add this method in (I added mine after the Application_Error method)

    public override string GetVaryByCustomString(HttpContext context, string custom)
    {
        switch (custom.ToUpper())
        {
            case "RAWURL":
                return context.Request.RawUrl;


            default:
                return "";
        }
    }

That's it, this will cache each category page for 1 hour including the filters and paged pages - If you want to cache for less than an hour then change the 600 to a lesser amount.

Category Canonical Tag

Following on from the category listing page theme… There is a bit of a duplicate content problem with the category listing pages (As with a lot of eCommerce solutions), and what I mean here is that you can get the same content from A LOT of different Url's especially if you have a lot of custom specifications you are allowing people to filter on.

The best way round this is to add the canonical tag in your page head, if you don't know about the canonical tag then you need to read up more about it here ( http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html) - You can use the code below straight away, but you will need to add some of your own settings which I'll explain below for product specifications - Open up the Category.aspx.cs file and at the bottom of the PageLoad add the following

AddCanonicalTag();

Then anywhere in this page add the following method

        private void AddCanonicalTag()
        {
            var url = Request.Url.ToString();
            var thisurl = url;        
            var querystringstocheck = new List<string>
                                          {
                                              "price=",
                                              "pageindex="
                                          };

            foreach (var qs in querystringstocheck)
            {
                if(thisurl.Contains(qs))
                {
                    // Found one of the querystrings, need to add canonical
                    var canonicalurl = url.Split('?');
                    var link = new HtmlGenericControl("link");
                    link.Attributes.Add("href", canonicalurl[0]);
                    link.Attributes.Add("rel", "canonical");
                    this.Page.Header.Controls.Add(link);
                    return;
                }
            }
            
        }

This will work out the box and will add a canonical tag for the paging and if you have a price filter enabled for the category, however it won't work for product specifications/attribute filters. You will need to add these in yourself, as they are custom dependant to your store - All you need to do is check what Catalogue > Attributes > Product Specifications you have in the admin section.

And then just add them into the 'querystringstocheck' list<string> with a '=' at the end - Remembering to remove all spaces and make them lower case.  So for example if I have the following Product specifications

T Shirt Size
Jumper Colour

I would add them like so

var querystringstocheck = new List<string>
                                          {
                    "price=",
                    "pageindex=",
                    "tshirtsize=",
                    "jumpercolour="
                                          };

Happy Nop'ing.

P.S. After looking at the above method, you could make it even simpler and actually just look for any query string value and add the canonical tag!

Back to top