Mvc. Site. Map. Provider 4. SEO Features Tutorial. In Mvc. Site. Map. Provider 4. 0 - A Test Drive we took a quick look at Mvc. Site. Map. Provider, focusing mainly on how to install it and use the main navigation features. Today, we will go into more depth about the SEO features of Mvc. Site. Map. Provider, as assisting to manage SEO in ASP. NET MVC is one of its main benefits. This is an Mvc. Site. Map. Provider SEO tutorial, so to speak. The code for everything discussed here is available for download at the bottom of this article. MVC Sitemap Provider tutorial. This command will then download the. We are now calling the MvcSiteMap library and telling it to output the. The top menu shipped in the default MVC3 template don't have support for highlighting the selected node. Download the MVC Sitemap. Using Menu and Sitemap with Master Page. Download demo project. I'm using @Html.MvcSiteMap().SiteMapPath() to build breadcrumbs trail. I have two controllers, one is DealsController which inherited from class of DealsContorllerBase. MvcSiteMapProvider - An ASP.NET MVC. What about using the template name to determine if there is an. Title HTML Helper. SEO experts agree that the #1 on- page ranking factor for SEO is a the Title attribute. It is important that your main 2 key phrases are in this tag to rank well in the search results. I am going to demonstrate how to use the Site. Map. Title HTML helper extension so you can use it to build all or part of the page’s < title> tag and also use it to build the page’s main header, or < h. We’re going to use the same project we used last time, which is basically just the MVC4 Internet template with Mvc. Site. Map. Provider. MVC4 installed. Start by opening the Views/Shared/. We need to change the title tag. It currently looks like this: < title> @View. Bag. Title - My ASP. NET MVC Application< /title>. We need to change that first part to point to our sitemap title instead: < title> @Html. Mvc. Site. Map(). Site. Map. Title() - My ASP. NET MVC Application< /title>. Run the project by clicking F5, and look at the title in your browser. As you can see, instead of “Home Page – My ASP. NET MVC Application”, it now reads “Home – My ASP. NET MVC Application”. Next, we need to alter each of the pages to change the title of the < h. Mvc. Site. Map. Provider, rather than being hard coded. Here is what the top part of the Views/Home/Index. We also need to change the < h. Mvc. Site. Map. Provider. Here is the result of those changes: @section featured . You should also make similar changes to the pages in the Account folder as well, but we won’t be going into that here. Here is the current About and Contact page code (top section only). About. cshtml: @. The About and Contact pages are also now reading their title values from Mvc. Site. Map. Provider. Canonical Tag HTML Helper. There is a lot of confusion around SEO and what is referred to as a “duplicate content penalty”. Google insists that there is no actual penalty if you make 2 URLs that point to the same content, but if you do, you will definitely not be able to rank very high. Does the site work if you remove this line @Html.MvcSiteMap().SiteMapPath()? The reason is because there is no way for Google or other search engines to detect this scenario automatically. However, there is a way you can tell the search engines “it is supposed to be on 2 URLs, but ignore all but this one” – the Canonical Tag. Mvc. Site. Map. Provider has the means to automatically generate this tag for you as well as the means to configure the “master copy”. It will also synchronize the automatic sitemaps XML end point to automatically exclude the “duplicate” URLs, so everything you tell the search engines about these “duplicate URLs” is consistent. Let’s alter the Views/Shared/. Note that the code must be placed between the < head> and < /head> tags.< head>. Let’s change the About page to exist on 2 different URLs to demonstrate how this works. The simplest way to do that is to add a custom attribute to a copy of the node, which will then be appended to the URL. Note that if you need another node to match when the “something” query string parameter is not supplied, you need to manually specify to match an empty string.< mvc. Site. Map. Node title=. Clicking on the “Another About” link shows that it indeed goes to a different URL than clicking “About” (/Home/About? Home/About). Why would anyone do this? Admittedly, this example is contrived to show how it can be done, not why you would want to. The canonical tag feature is most useful if you have items that belong to more than one category and want to have different breadcrumb trails for each category. For example, the product “Blue Diamonds” might belong to the category “Blue Things” and the category “Diamonds”, and depending on where the user navigated to the product from, you may want to show a different sitemap path. Products > Blue Things > Blue Diamonds. O Developing ASP.NET MVC 4 Web Applications Companion Content ii. In the Select a Template list of the New. In MvcSiteMapProvider 4.0 - A Test Drive we took a quick look at MvcSiteMapProvider, focusing mainly on how to install it and use the main navigation features. Forum thread about ASP.NET MVC - Kendo Grid with Cascading DropDown List - Need Dropdown Text in UI for ASP.NET MVC. Join the conversation now. Products > Diamonds > Blue Diamonds. You can do this by making 2 different nodes pointing to your Blue Diamonds product, and then “fixing” it for SEO by adding a rule for which one is the authoritive page. Let’s go back to our original example and do just that. We already have 2 URLs that point to the same resource. All we need to do now is configure the “duplicate” node with either a canonical. Url or a canonical. Key attribute. Let’s start by doing a canonical URL to demonstrate how it works: < mvc. Site. Map. Node title=. If you click over to the “About” page and view the source, you will notice that there is no canonical tag. Technically, the original page doesn’t need one. Now, it would be a real pain to always have to synchronize your URLs in your configuration across multiple nodes. Usually, a better option is to use the key of the node because it is something that doesn’t need to change. Let’s start by giving our “About” node a key. It can be anything (as long as it is unique within the sitemap), but for our example, we will just use the word “About”.< mvc. Site. Map. Node title=. Type the path /sitemap. URL /Home/About? something=1. Home/About is there. The robots meta tag, sometimes referred to as meta robots is used to tell search crawlers how to treat a page. There are a few options from specifying whether to index, cache, or follow the links on the page. NOTE: The official specification of this tag allows you to send different instructions to different search crawlers. However Mvc. Site. Map. Provider currently only supports one set of instructions to send to all search crawlers. Mvc. Site. Map. Provider supports the following options: Option. Descriptionindex. Allow search engine robots to index the page, you don't have to add this to your pages, as it's the default. May not be used in conjunction with noindex or none. Disallow search engines from showing this page in their results. May not be used in conjunction with index or none. Tells the search engine robots to follow the links on the page, whether it can index it or not. May not be used in conjunction with nofollow or none. Tells the search engine robots to not follow any links on the page at all. May not be used in conjunction with follow or none. This is a shortcut for 'noindex,nofollow', or basically saying to search engines: don't do anything with this page at all. May not be used in conjunction with index, noindex, follow, or nofollow. Prevents the search engines from showing a cached copy of this page. Same as noarchive, but only used by MSN/Live/Bing. Prevents the search engines from showing a snippet of this page in the search results and prevents them from caching the page. Same as nosnippet, but only used by Bing. Blocks search engines from using the description for this page in DMOZ (aka ODP) as the snippet for your page in the search results. Blocks Yahoo! No other search engines use the Yahoo! First, let’s drop the Html. Mvc. Site. Map(). Meta. Robots. Tag() HTML helper into our Views/Shared/. Let’s change that by editing Mvc. For example, let’s say we want to override the default settings that ODP and Yahoo! We want the search engines to index and follow our home page, so we will tell them explicitly (note that if we don’t tell them explicitly, this is the default anyway). We also don’t want the search engines to index our Contact page because we don’t want anyone to contact us, really (reminds me of a lot of businesses I know).< mvc. Site. Map. Node title=. If we run our project and view the source of the home page, we will now have a meta tag generated with these values inside our < head> tag.< meta name=. Now, have a look at our sitemaps XML endpoint by manually typing in /sitemap. As you can see, our contact page is still there. Because we only told the search engine not to index the page, but we still want it crawled so the links are followed to other pages. Let’s say we wanted to change it so that isn’t the case – we just need to add a nofollow tag to the configuration for that page: < mvc. Site. Map. Node title=. Also take a look at our sitemaps XML endpoint at /sitemap. Contact page is now gone from the results. We are consistently telling the search engine “hands off” the Contact page in both the robots meta tag and the sitemap. You might be surprised to discover that with all of this SEO goodness that there is no built- in support for Meta Keywords and Meta Description tags in Mvc. Site. Map. Provider. The reason for this is that everything we configure in the Mvc. This description only has value when navigating to the page it belongs to, so there is no point in adding it to the cache. I recommend the use of the Meta Description tag even though Mvc. Site. Map. Provider has no native support. This is where you need to write your marketing hype. This text is used by default in the snippet that appears below your link in the search results. The only value that keywords have here is that they will be highlighted if there is a match, but don’t expect them to give you better rankings, just a better click- through rate. Never use your key phrase more than 2 times – it is not likely to fit more than that anyway. SEO experts generally agree that the Meta Keywords tag is obsolete and you shouldn’t waste your time writing anything to support it. In fact, it is likely that its only true purpose anymore is to catch spammers who are trying to trick the search engines by feeding them irrelevant keywords. This cannot happen if you don’t use Meta Keywords at all, but could if you do. So, I say don’t bother. Both of these tags can be configured in a similar way to the way the page title was configured by default – by adding them to the view directly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2016
Categories |