How to Setup Sitemaps in ASP.NET
See more tutorials in Web Forms. This post has Comments Off on How to Setup Sitemaps in ASP.NET.
In This tutorial we will teach you how to create and setup Sitemaps in ASP.NET. Sitemaps can be used in different ways, some developers use it as a layout before creating a site. It also has information that is helpful to Search Engine crawlers so that they can index your entire site rather than the pages that are most popular. Sitemaps are a simple easy step to take in order to boost your SEO.
Step 1. Setting up the Project
1. Create a new empty project in Visual Web Developer
2. In Solution explorer add a new Web Form and name it “Default.aspx”
3. Now create a new folder in the Root of you Project and name it “Nested”
4. Now create a new Web Form inside that “Nested” Folder called “NestedForm.aspx”
5. Now we have a very simple hierarchy for our website we can begin working in the sitemap file.
Step 2. Setting up the Sitemap
1. Right Click on your solution explorer and Navigate to Add-> New Item
2. Create a new Web Form and name it “Web.sitemap” Note the Default name is recommended for sitemaps as most projects will have only one.
3. Sitemaps are comprised of Sitenodes. These Sitenodes are essentially links to all of the pages in your website where “~/” is the Root of your project. The SiteNodes require one tag with a beginning and ending tag, and inside the sitenode tag is any number of other sitenode tags without ending tags like below:
4. It may appear to be a weird setup using one tag in two different ways, but that is the way they wish to set them up. Just put your Home Page in the Opening and all of your other sites can be nested in side like our code example below.
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/default.aspx" title="Home" description="Home Page">
<siteMapNode url="~/Nested/NestedForm.aspx" title="Nested Web Page" description="This page is nested in a folder" />
In this tutorial we learned how to create Sitemaps and set them up to help in many different stages of development. They can be useful before and after you create your website for either a layout or helping in SEO. One thing is for sure though, they can be setup simply and can always be useful.