-
Notifications
You must be signed in to change notification settings - Fork 218
Exporting the sitemap for search engine indexing
When building a website, chances are that you want to provide an XML sitemap used for search engine indexing.
If you just require a sitemap.xml file to be available, consider adding the following line of code in the Application_Start event:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using MvcSiteMapProvider.Web;namespace MvcMusicStore { public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { // ... your routes registration here }
<span style="color: blue;">protected</span> <span style="color: blue;">void</span> Application_Start() { AreaRegistration.RegisterAllAreas(); XmlSiteMapController.RegisterRoutes(RouteTable.Routes); <span style="color: green;">// <-- register sitemap.xml, add this line of code</span> RegisterRoutes(RouteTable.Routes); } }
}
This will make sitemap.xml available in the easiest way.
Whenever a sitemap exceeds 50.000 nodes, the XmlSiteMapController will automatically split your sitemap into a sitemap index file (sitemap.xml) which references sub-sitemaps (sitemap-1.xml, sitemap-2.xml etc.) as described on http://www.sitemaps.org/protocol.php.
The XmlSiteMapResult class creates an XML sitemap that can be submitted to Google, Yahoo and other search engines to help them crawl your website better. The usage is very straightforward:
public class HomeController { public ActionResult SiteMapXml() { return new XmlSiteMapResult(); } }
Optionally, a starting node can also be specified in the constructor of theXmlSiteMapResult .
Whenever a client sends an HTTP request header with Accept-encoding set to a value of gzip or deflate, the XmlSiteMapResult class (which is also used internally in the XmlSiteMapController) will automatically compress the sitemap using GZip compression.
Want to contribute? See our Contributing to MvcSiteMapProvider guide.
- Registering the provider
- Creating a first sitemap
- Defining sitemap nodes in code
- Dynamic sitemaps
- HtmlHelper functions
- Action Filter Attributes
- Exporting the sitemap for search engine indexing
- Advanced node visibility
- Extension points
Other places around the web have some documentation that is helpful for getting started and finding answers that are not found here.
- MvcSiteMapProvider 4.0 - A Test Drive
- MvcSiteMapProvider 4.0 - SEO Features Tutorial
- How to Make MvcSiteMapProvider Remember a User’s Position
- MvcSiteMapProvider 4.0 - Cache Configuration
- MvcSiteMapProvider 4.0 - Extending the Cache
- MvcSiteMapProvider 4.0 - Unit Testing with the SiteMaps Static Methods
- Debugging an MvcSiteMapProvider Configuration
- Converting from C# to Vb MvcSiteMapProvider
- ASP.NET MVC Menu using Site Map Provider & Bootstrap 3 Navbar
- ASP.NET MVC SiteMapPath using Site Map Provider & Bootstrap Breadcrumbs
- NightOwl888's MvcSiteMapProvider Demos - Filter for "MvcSiteMapProvider" to see the most relevant.
- MvcSiteMapProvider Tutorial and Examples
- MvcSiteMapProvider Tutorial 2 - Breadcrumbs
- Getting Started with MvcSiteMapProvider
- Inside the MvcSiteMapProvider - Part 1
- Inside the MvcSiteMapProvider - Part 2: Dynamic node providers
- Inside the MvcSiteMapProvider - Part 3: The ISiteMapVisibilityProvider
- Inside the MvcSiteMapProvider - Part 4: The IAclModule
- Inside the MvcSiteMapProvider - Part 5: The ISiteMapNodeUrlResolver
- Styling MvcSiteMapProvider with CSS
- Using MvcSiteMapProvider with Twitter Bootstrap
- ASP.NET MVC Menu using Site Map Provider & Bootstrap Navbar