C# 结合asp.net mvc正确使用microdata itemscopes
因为我使用的是asp.net MVC,所以在我的身体中使用@RenderBody()呈现视图C# 结合asp.net mvc正确使用microdata itemscopes,c#,asp.net-mvc,schema.org,microdata,C#,Asp.net Mvc,Schema.org,Microdata,因为我使用的是asp.net MVC,所以在我的身体中使用@RenderBody()呈现视图 我的问题是:我是否正确使用了schema.org微数据? 在我的示例中,我有一个html,它是WebSite,在WebSite itemscope的标题中有一些元数据。 接下来,我将maintentityofpage设置为WebPage,并添加页眉、页脚。 在@RenderBody()中显示的某些页面具有自己的作用域(例如ContactPage),而其他页面仅具有产品或地点的某些ItemScope的数据
我的问题是:我是否正确使用了schema.org微数据? 在我的示例中,我有一个html,它是WebSite,在WebSite itemscope的标题中有一些元数据。 接下来,我将maintentityofpage设置为WebPage,并添加页眉、页脚。 在@RenderBody()中显示的某些页面具有自己的作用域(例如ContactPage),而其他页面仅具有产品或地点的某些ItemScope的数据 这是使用微观数据的正确方法吗 简化布局.cshtml
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebSite">
<head prefix="og: http://ogp.me/ns#">
<meta property="og:title" content="test">
<meta itemprop="about" content="test">
</head>
<body itemprop="mainEntityOfPage" itemscope itemtype="http://schema.org/WebPage">
<div class="myheader" itemscope itemtype="http://schema.org/WPHeader">
<div class="...">
<nav class="navbar navbar-default navbarwrapper" itemscope itemtype="http://schema.org/SiteNavigationElement">
@*...*@
</div>
</div>
</div>
@RenderBody()
<div>
@* some other stuff*@
</div>
<div class="myfooter" itemscope itemtype="http://schema.org/WPFooter">
@*...*@
</div>
</body>
@*...*@
@RenderBody()
@*一些其他的东西*@
@*...*@
简化的Index.cshtml(Home),显示在@RenderBody()中,因此在没有任何其他itemscope的网页itemscope中:
<div class="...">
@* content *@
</div>
@*content*@
简化的Contact.cshtml(Home),显示在@RenderBody()中,因此在网页itemscope和其他作用域中:
<div class="banner">
@* banner stuff *@
</div>
<div class="myMiddleContent" itemscope itemtype="http://schema.org/ContactPage">
<div class="container">
<div class="row">
@*...*@
<div class="col-md-6" itemscope itemtype="http://schema.org/Place">
@*...*@
</div>
</div>
</div>
</div>
@*横幅材料*@
@*...*@
@*...*@
更新:
这就是我现在拥有的:
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/WebSite">
<head prefix="og: http://ogp.me/ns#">
<meta property="og:title" content="test">
<meta itemprop="about" content="test">
<meta itemprop="headline" content="my fancy pancy site">
<meta itemprop="cool, things here">
</head>
<body itemprop="mainEntity" itemscope itemtype="http://schema.org/ContactPage"> @* or /WebPage *@
<div class="myheader" itemprop="hasPart" itemscope itemtype="http://schema.org/WPHeader">
<div class="...">
<nav class="navbar navbar-default navbarwrapper" itemprop="hasPart" itemscope itemtype="http://schema.org/SiteNavigationElement">
@*...*@
</div>
</div>
</div>
@* injected via @RenderBody() *@
<div class="banner">
@* banner stuff *@
</div>
<div class="myMiddleContent">
<div class="container">
<div class="row">
@* list of products...*@
<div class="col-md-6" itemscope itemtype="http://schema.org/Product">
@*product x...*@
</div>
<div class="col-md-6" itemscope itemtype="http://schema.org/Product">
@* product y...*@
</div>
</div>
</div>
</div>
<div itemprop="contentLocation" itemscope itemtype="http://schema.org/Museum">
<link itemprop="additionalType" href="http://schema.org/TouristAttraction">
<meta itemprop="name" content="Foo bar">
<meta itemprop="sameAs" content="http://www.facebook.com/FooBar">
<div itemprop="openingHoursSpecification" itemscope itemtype="http://schema.org/OpeningHoursSpecification">
@*...*@
</div>
</div>
@* end of injected via @RenderBody() *@
<div>
@* some other stuff*@
</div>
<div class="myfooter" itemprop="hasPart" itemscope itemtype="http://schema.org/WPFooter">
@*...*@
</div>
@*website/webpage creator / author / etc... *@
<div itemprop="creator" itemscope itemtype="http://schema.org/LocalBusiness">
<meta itemprop="name" content="...">
@*...*@
</div>
<div itemprop="copyrightHolder" itemscope itemtype="http://schema.org/LocalBusiness">
@*...*@
</div>
</body>
</html>
@*或/网页*@
@*...*@
@*通过@RenderBody()注入*@
@*横幅材料*@
@*产品列表*@
@*产品x*@
@*产品y*@
@*...*@
@*通过@RenderBody()注入的结束*@
@*一些其他的东西*@
@*...*@
@*网站/网页创建者/作者/等...*
@*...*@
@*...*@
由于Index.cshtml中没有模式标记,我将在插入_Layout.cshtml时讨论Contact.cshtml。这适用于Index.cshtml,但引用Contact.cshtml中的内容时除外
架构标记如下所示:
- 网站
- 页面维护:网页
- WPHeader
- SiteNavigationElement
- 联系页
- 放置
- 页脚
此标记通知此页面上的HTML是网站。这很好,但可能不是你想要的。术语对于模式标记很重要-也许这应该是一个网页?我稍后再谈这个问题
在这里,你说的是网站是网页的主体:网页。这几乎肯定不是你想要的。为了澄清,你说的网页(这一个页面)主要实体(这一个页面的主要内容)是网站(整个网站)。我鼓励您检查该物业的规格。以下是我将要做的:
删除itemprop将删除网页到网站的链接,并且由于您没有使用任何网站属性,因此可以删除网站架构
@*...*@
这是两个完全不同的模式。它们彼此不关联,也不与网页架构关联。这两个上都缺少itemprop属性。两者都应包括itemprop=“hasPart”
,以定义以下层次结构:
- 网页
- hasPart:WPHeader
- hasPart:SiteNavigationElement
- hasPart:WPHeader
@*横幅材料*@
这有点困难,因为ContactPage是一个网页,但您已经在一个网页的范围内,因此它不是一个不同的网页。通常您会将这两个链接到itemprop=“maintentity”
,但项目类型是网页,因此这是不正确的。页面的mainContentOfPage用于WebPageElement,但您再次定义了整个页面
这是应该用ContactPage替换网页模式的地方,但我知道您的@RenderBody()
的“插入”不适合这种情况。如果不能根据插入的页面更改网页模式(网页仍然是Index.cshtml最合适的模式),我想mainEntity是最好的选择。如果您能够在插入联系人页面时更改布局页面,则应将该页面更改为联系人页面,而不是使用mainEntity。由于后面讨论的联系人页面中的模式适用于联系人页面模式,因此您不需要在以后进行任何进一步的更改
到目前为止,假定您在插入联系人页面时无法更改布局页面,架构如下:
- 网页
- hasPart:WPHeader
- hasPart:SiteNavigationElement
- 主实体:联系人页面
- hasPart:WPHeader
@*...*@
到目前为止,这个地方与任何东西都是完全分离的——同样,这个模式中缺少一个itemprop。使用contentLocation(或定义一个组织/etc来包含地点)。然后,你将以
- 网页
- hasPart:WPHeader
- hasPart:SiteNavigationElement
- 主实体:联系人页面
- 地点:地点
- hasPart:WPHeader
@**@
@*一些其他的东西*@
与WPHeader一样,WPFooter缺少hasPart。完成的sc