The Sitemap protocol allows you to inform search engines about URLs on your websites that are available for crawling. In its simplest form, a Sitemap that uses the Sitemap protocol is an XML file that lists URLs for a site. The protocol was written to be highly scalable so it can accommodate sites of any size. It also enables webmasters to include additional information about each URL (when it was last updated; how often it changes; how important it is in relation to other URLs in the site) so that search engines can more intelligently crawl the site.
A sample Sitemap that contains just one URL and uses all optional tags is shown below. The optional tags are in italics.
The Sitemap must:
- Begin with an opening
<urlset> tag and end with a closing
- Include a
<url> entry for each URL as a parent XML tag.
- Include a
<loc> child entry for each
<url> parent tag.
||Encapsulates the file, and references the current protocol standard.
||Parent tag for each URL entry. The remaining tags are children of this tag.
||URL of the page. This URL must begin with the protocol (such as HTTP) and end with a trailing slash, if your web server requires it. This value must be less than 2048 characters.
||The date of last modification of the file. This date should be in W3C Datetime format. This format allows you to omit the time portion, if desired, and use YYYY-MM-DD.
How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Valid values are:
The value "
always" should be used to describe documents that change each time they are accessed. The value "
never" should be used to describe archived URLs.
Please note that the value of this tag is considered a hint and not a command. Even though search engine crawlers consider this information when making decisions, they may crawl pages marked "hourly" less frequently than that, and they may crawl pages marked "yearly" more frequently than that. It is also likely that crawlers will periodically crawl pages marked "never" so that they can handle unexpected changes to those pages.
The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0. This value has no effect on your pages compared to pages on other sites, and only lets the search engines know which of your pages you deem most important so they can order the crawl of your pages in the way you would most like.
The default priority of a page is 0.5.
Please note that the priority you assign to a page has no influence on the position of your URLs in a search engine's result pages. Search engines use this information when selecting between URLs on the same site, so you can use this tag to increase the likelihood that your more important pages are present in a search index.
Also, please note that assigning a high priority to all of the URLs on your site will not help you. Since the priority is relative, it is only used to select between URLs on your site; the priority of your pages will not be compared to the priority of pages on other sites.
Create Site Map XML File Dynamically
I use the
XmlWriter class to write Sitemap's XML tags. Before using the
XmlWriter, class you should import the
System.Xml namespace with the
using keyword .
Then create a
WriteTag that writes each Google sitemap XML block and call it in the Page Load event code block.
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
XmlWriter writer = XmlWriter.Create(Server.MapPath("GSiteMap.xml"));
WriteTag("1", "Daily", "http://www.delshad.ir/default.aspx", writer);
WriteTag("0.6", "Yearly", "http://www.delshad.ir/Contact.aspx", writer);
WriteTag("0.8", "Monthly", "http://www.delshad.ir/About.aspx", writer);
private void WriteTag(string Priority, string freq,
string Navigation, XmlWriter MyWriter)
You can call the
WriteTag method in a loop that reads data from the database. Note that you should set the write permission for your XML file (GSiteMap.xml). After you finish up writing the ASP.NET code and uploading it, you should add your site map in Google Webmaster Tools.
If you do not have any Google account, first create an account then go to Google Webmaster Tools.
After logging in Webmaster Tools, add your website URL in the dashboard, then select SiteMap>Add SiteMap, then choose "Add General Web SiteMap" from the dropdown list. Type your XML SiteMap file in the SiteMap URL textbox (for example: GSiteMap.xml), then click Add. After adding your SiteMap, you should verify it. To verify your SiteMap, go to Dashboard and select Verify from the SiteMap's list.