ASP.NET站点地图,有多重要? [英] ASP.NET sitemap , how important?

查看:153
本文介绍了ASP.NET站点地图,有多重要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了我的网站,我这样想着。我没有一个网站地图和一些奇迹,我已经错过了一个网站地图的整个概念,甚至不知道这是一件事。大大喊答题节目环节到我的CS老师,我猜。

I am finished with my website, or so I thought. I don't have a sitemap and by some miracle I've missed the entire concept of a sitemap, didn't even know it was a thing. Big shoutout to my CS teachers I guess.

我已经在这读了,它似乎相当复杂的动态生成网站地图,这是我必须做的,因为我的网页基本上只是在那里你使用搜索参数的大数据库。

I've been reading up on it and it seems quite complicated to generate sitemap dynamically, which I have to do since my page is basically just a big database where you search using parameters.

这是多么重要的谷歌搜索引擎的相关性等?例如,如果有人搜索我的网站在谷歌这样的www.mySite.com食品。如果我有我的数据库一类名为食品而事实上如果有人使用我的网站上搜索,他们会发现一个食物类别,但谷歌会知道这个?将谷歌找到www.mySite.com/Find?Result=food

How important is this for Google search engine relevance etc? For example, if someone searches for my website on google like this "www.mySite.com food". If I have a category in my database called "food" and indeed if someone uses the search on my site they will find a food-category, but will Google know this? Will Google find "www.mySite.com/Find?Result=food"?

编辑:?它甚至正确使用Web.sitemap中,你可以在ASP.NET创建或者我应该使用一个名为sitemap.txt文件

Is it even correct to use Web.Sitemap that you can create in ASP.NET or should I use a file called sitemap.txt?

推荐答案

有3种不同网站地图。


  1. 具有该给他们的网站结构的完整轮廓可以帮助用户在其上链接的页面。这有时,但并非总是如此,如下站点层次结构。此外,它通常限于大类的部位。细节页面不能正常上市。

  2. 在ASP.NET的系统,有助于建立菜单,面包屑小径和网站的其他导航功能。这是由一个供应商,在默认情况下使用 .sitemap XML文件驱动。

  3. 一个XML文件,提供链接到该网站的网页约当网页最后更新的信息一起,这是多么重要的更新等,以协助在搜索引擎索引的网站。

  1. A page that has links on it that assists users by giving them a complete outline of the site structure. This sometimes, but not always, follows the site hierarchy. Also, it is usually limited to major categories of the site. The detail pages are not normally listed.
  2. A system in ASP.NET that helps to build menus, breadcrumb trails, and other navigation features of the site. This is driven by a provider that by default uses .sitemap XML files.
  3. An XML document that provides links to the site's pages along with information about when the page was last updated, how important it is to update, etc. to assist with indexing the site in search engines.

如果你看看历史,它使解析此信息少一点混乱。上述名单是按时间顺序。 网站地图本来是给提供链接到网站的主要部分用户页面的术语。微软决定再次使用站点地图来称呼自己的导航系统ASP.NET 2.0。几年以后,各大搜索引擎联手提供有关网站的URL信息提供的XML规范,他们不幸超载术语站点地图再次来形容他们。

A Brief History

If you look at the history, it makes parsing this information a bit less confusing. The above list is in chronological order. "Site map" was a term originally given to provide a user page that linked to the major sections of the web site. Microsoft decided to again use the term "site map" to refer to their navigation system for ASP.NET 2.0. Some years later, the major search engines teamed up to provide an XML specification for providing URL information about sites, and they unfortunately overloaded the term "site map" once again to describe them.

一个这段历史的后果是,ASP.NET有没有内置的XML网站地图,它听起来像你想根据你的问题作出支持。这主要是因为微软的实施并没有改变(很多),因为ASP.NET 2.0,它是写之前规范结出了硕果。因此,使用微软的ASP.NET导航系统对你没有好处生成一个XML站点地图的目的。

One of the consequences of this history is that ASP.NET has no built-in support for XML sitemaps, which it sounds like you are trying to make based on your question. This is primarily because Microsoft's implementation hasn't changed (much) since ASP.NET 2.0 and it was written before that specification came to fruition. So, using Microsoft's ASP.NET navigation system will do you no good for the purpose of generating an XML sitemap.

做然而要注意的 3的所有这些项目的是搜索引擎优化重要的。

Do note however that all 3 of these items are important for SEO.


  1. 的用户站点地图,搜索引擎索引帮助,因为它提供了内在的网站链接到需要被索引的主要领域。

  2. 菜单和浏览路径记录是很重要的所有内容页面的链接给对方,这有助于该网站的不同部分之间的相关标识。

  3. XML站点地图提供的搜索引擎直接的URL信息,并有助于减少网站上的搜索引擎的流量,并帮助确保有一些搜索引擎没有考虑到索引没有重要的网址。

所以,你可能希望每个这些考虑到,虽然严格来说他们都是可选的。

So you may want to take each of these into consideration, although strictly speaking all of them are optional.

SEO是关于第一个提供良好的内容,然后做必要的步骤,使内容能够访问。上述每个应考虑SEO,如果向前迈进了一步,你真正关心的搜索引擎排名,你应该尽一切可能,包括所有步骤3。

SEO is about first providing good content, and then doing the required steps so that content is accessible. Each of the above should be considered a step forward for SEO and if you really care about search engine placement, you should do all that is possible, including all 3 of these steps.

其实, XML网站地图规范是pretty简单下50,000页的小网站。因此,它通常并不需要很多的努力,把它们放在一起。您可能要考虑这个做你自己。

Actually, the XML sitemap specification is pretty simple for small sites under 50,000 pages. So it generally doesn't take much effort to put them together. You may want to consider doing this yourself.

大多数开放源代码实现的不是很可扩展性,因为它们都是整个数据集的加载到内存中一次生成XML流,而不是它的。此外,大多数人并没有真正考虑的事实,你可能有多个表,所有有助于网站的网址,动态数据。他们通常把它留给你提供分页。大多数现有的实现还没有提供的<一href=\"http://searchengineland.com/google-xml-sitemaps-now-supports-multiple-types-is-the-sitemaps-alliance-over-45406\"相对=nofollow>专门的内容通过谷歌提供的类型。

Most of the open source implementations are not very scalable because they all load the entire set of data into memory at once to generate the XML instead of streaming it. Also, most of them don't really account for the fact that you might have dynamic data in multiple tables that all contribute to the URLs of the web site. They usually leave it up to you to provide paging. Most of the existing implementations also do not provide the specialized content types offered by Google.

我最近创建实现做所有这些事情。这还没有正式发布,目前它是 MvcSiteMapProvider 项目的一部分。我们计划到XML网站地图的功能分成不同的组件(和独立的NuGet包),所以它不必引用MVC但可以使用现在MVC是一个必要条件(当然,除非你想抓住所有相关类型,并把它们编译到一个单独的DLL自己)。它与MVC ASP.NET项目仍然会运行得很好,所以这不是太大的问题对于大多数的项目。

I have recently created an implementation that does all of these things. It has not officially been released, and it is currently part of the MvcSiteMapProvider project. We have plans to separate the XML sitemap functionality into a different assembly (and separate NuGet package) so it can be used without referencing MVC but for now MVC is a requirement (unless of course you want to grab all of the relevant types and compile them into a separate DLL yourself). An ASP.NET project with MVC in it will still run just fine, so this isn't that much of an issue for most projects.

有没有在这一点上的任何文件,但我已经创建了一个<一个href=\"http://stackoverflow.com/questions/28297293/how-to-link-to-a-child-site-map-file-from-a-parent-site-map-in-asp-net-mvc4-usin/28330749#28330749\">quick帖子展示了如何把它在MVC,其中包括演示应用。

There isn't any documentation at this point, but I have created a quick post showing how to wire it up in MVC, including a demo application.

有关ASP.NET中,您既可以使用MVC实现(如果安装MvcSiteMapProvider,它将MVC安装到你的项目是这样),或者你可以只使用一个ASP.NET页面。

For ASP.NET, you could either use the MVC implementation (if you install the MvcSiteMapProvider, it will install MVC into your project anyway), or you could just use an ASP.NET page.

在第二种情况下,在配置看起来有少数例外类似

In the second case, the configuration would look similar with a few exceptions.


  1. 您不需要使用 XmlSitemapFeedRouteRegistrar 类。

  2. 您(当然)并不需要使用控制器,你将取代与ASP.NET页面,如下所示:

XmlSitemap.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XmlSitemap.aspx.cs" Inherits="XmlSitemap" %>

XmlSitemap.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MvcSiteMapProvider.IO;
using MvcSiteMapProvider.Xml.Sitemap;
using MvcSiteMapProvider.Xml.Sitemap.Configuration;

public partial class XmlSitemap : System.Web.UI.Page
{
    private HttpContextBase HttpContext
    {
        get { return new HttpContextWrapper(System.Web.HttpContext.Current); }
    }

    private int PageNumber
    {
        get
        {
            var pageString = HttpContext.Request.QueryString["page"];
            if (!string.IsNullOrEmpty(pageString))
            {
                int page;
                if (int.TryParse(pageString, out page))
                {
                    return page;
                }
            }
            return 0;
        }
    }

    private string FeedName
    {
        get
        {
            var feedName = HttpContext.Request.QueryString["feedName"];
            if (!string.IsNullOrEmpty(feedName))
            {
                return feedName;
            }
            return "default";
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        // Build feeds for XML sitemap
        var xmlSitemapFeedStrategy = new XmlSitemapFeedStrategyBuilder()
            .SetupPageNameTempates(templates => templates
                .WithDefaultFeedRoot("XmlSitemap.aspx?feedName={feedName}&page={page}")
                .WithDefaultFeedPaged("XmlSitemap.aspx?feedName={feedName}&page={page}")
                .WithNamedFeedRoot("XmlSitemap.aspx?feedName={feedName}&page={page}")
                .WithNamedFeedPaged("XmlSitemap.aspx?feedName={feedName}&page={page}"))
            .AddDefaultFeed()
            .AddNamedFeed("google", feed => feed.WithContent(c => c.Image().Video()))

            // Optional - add news feed (will be at ~/XmlSitemap.aspx?feedName=news)
            .AddNamedFeed("news", feed => feed.WithContent(c => c.News()))

            // Optional - add mobile feed (will be at ~/XmlSitemap.aspx?feedName=mobile)
            .AddNamedFeed("mobile", feed => feed.WithContent(c => c.Mobile()).WithMaximumPageSize(10000))
            .Create();

        var xmlSitemapFeed = xmlSitemapFeedStrategy.GetFeed(this.FeedName);

        if (xmlSitemapFeed != null)
        {
            var outputCompressor = new HttpResponseStreamCompressor();
            var response = HttpContext.Response;

            response.Clear();

            // Output content type
            response.ContentType = "text/xml";

            using (var stream = outputCompressor.Compress(HttpContext))
            {
                if (!xmlSitemapFeed.WritePage(this.PageNumber, stream))
                {
                    response.Clear();
                    //Return 404 not found
                    response.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                    response.StatusDescription = "Page Not Found";
                }
            }

            response.End();
        }
    }
}

上述配置实际上创建了4个不同的XML网站地图饲料,主要是为了遵守这些特殊类型的规范。

The above configuration actually creates 4 different XML sitemap feeds, mostly to adhere to the specification of these specialized types.


  1. 默认 - /XmlSitemap.aspx - 可与任何搜索引擎上使用的地图。此URL需要在你的的robots.txt 文件按照的 XML网站地图规范

  2. 谷歌 - /XmlSitemap.aspx?feedName=google - 该网站地图,包括从默认的相同的URL,但它也包括图像和视频内容的专业。由于不正确的codeD抓取,如果他们遇到任何谷歌的特殊类型的可能会崩溃,我已经把他们分开到不同的饲料。你需要通过自己的网站管理员工具来手动提交此网址到谷歌。

  3. 新闻中心 - /XmlSitemap.aspx?feedName=news - 这是谷歌的新闻站点地图功能,这需要提交的按照其规格的。

  4. 手机 - /XmlSitemap.aspx?feedname=mobile - 这是谷歌移动地图功能,这需要提交的按他们的规格

  1. Default - /XmlSitemap.aspx - A sitemap that can be used with any search engine. This URL needs to be in your robots.txt file as per the XML sitemap specification.
  2. Google - /XmlSitemap.aspx?feedName=google - This sitemap includes the same URLs from Default, but it also includes the Image and Video specialized content. Since incorrectly coded crawlers may crash if they encounter any of Google's specialized types, I have separated them into a different feed. You would need to manually submit this URL to Google through their webmaster tools.
  3. News - /XmlSitemap.aspx?feedName=news - This is for Google's news sitemap functionality, which needs to be submitted per their specifications.
  4. Mobile - /XmlSitemap.aspx?feedname=mobile - This is for Googles mobile sitemap functionality, which needs to be submitted per their specifications.

请注意的是,也可以使用路由ASP.NET中,使这些网址更好。你只需要确保名称模板的URL由路径产生同样的方式上述规定,把占位符 {feedName} {PAGE} 在URL中的适当位置。

Note that it is also possible to use routing in ASP.NET to make these URLs nicer. You just need to ensure that the name templates are specified above the same way that the URLs are generated by routes, putting the placeholders for {feedName} and {page} in the appropriate place in the URL.

请注意,根据XML网站地图的规范,一个XML站点地图不能包含任何网址,上面的虚拟目录的目录。所以,最好是确保您的路线不包含任何 / 字符(这意味着它适用于整个网站,而不是一个子目录)。

Do be aware that according to the XML sitemap specification, an XML sitemap cannot contain any URLs for directories above its virtual directory. So, it is best to ensure your route does not contain any / characters (meaning it applies to the whole site, not a subdirectory).

这篇关于ASP.NET站点地图,有多重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆