- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试在 umbraco cms 中呈现 seo 标签的 View 。但是我不确定如何完成。有没有我可以查阅的资源?
最佳答案
SEO 和社交媒体的标签可以结合使用,因为它们共享一些相同的信息。
在我的 umbraco 安装中,我将以下属性添加到网站根节点、页面节点和成员节点:
在顶层节点上:
在页面上
关于成员
然后我使用以下代码在所有页面上呈现 head 元标记:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
// SITE INFORMATION
string site_locale = "en_US";
if (Model.Content.AncestorOrSelf(1).HasProperty("siteLocale") && (Model.Content.GetPropertyValue<string>("siteLocale") != ""))
{ site_locale = Model.Content.GetPropertyValue<string>("siteLocale"); };
// Check if root node has defined site name, otherwise use domain name.
string domain = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority;
string site_name = Model.Content.AncestorOrSelf(1).HasProperty("siteName") ? Model.Content.AncestorOrSelf(1).GetPropertyValue("siteName").ToString() : HttpContext.Current.Request.Url.Host.ToString();
// Check if site description exist, and default text if not.
string site_description = Model.Content.AncestorOrSelf(1).HasProperty("siteDescription") ? Model.Content.AncestorOrSelf(1).GetPropertyValue("siteDescription").ToString() : "The website " + HttpContext.Current.Request.Url.Host.ToString();
string site_logo_url = "";
string site_logo_height = "";
string site_logo_width = "";
if (Model.Content.AncestorOrSelf(1).HasProperty("siteLogo") && (Model.Content.AncestorOrSelf(1).GetPropertyValue<int>("siteLogo") != 0))
{
var logo = Umbraco.TypedMedia(Model.Content.AncestorOrSelf(1).GetPropertyValue("siteLogo").ToString());
site_logo_url = domain + logo.Url;
site_logo_height = logo.GetPropertyValue<string>("umbracoHeight");
site_logo_width = logo.GetPropertyValue<string>("umbracoWidth");
}
string site_fb_app_id = Model.Content.AncestorOrSelf(1).GetPropertyValue("facebookAppId").ToString();
string site_fb_page_url = Model.Content.AncestorOrSelf(1).GetPropertyValue("facebookPageUrl").ToString();
string site_twitter_username = Model.Content.AncestorOrSelf(1).GetPropertyValue("twitterUserName").ToString();
// PAGE INFORMATION
// Use page title if defined, otherwise Model.Content.Name
string page_url = Model.Content.Url;
string page_title = Model.Content.HasProperty("pageTitle") ? Model.Content.GetPropertyValue("pageTitle").ToString() : Model.Content.Name.ToString();
DateTime page_created_date = Model.Content.CreateDate;
DateTime page_updated_date = Model.Content.UpdateDate;
string page_description = Model.Content.HasProperty("pageSnippet") ? Model.Content.GetPropertyValue("pageSnippet").ToString() : "";
// AUTHOR INFORMATION
// Check for information about the author of this page
bool hasAuthorInfo = false;
if (Model.Content.HasProperty("author") && (Model.Content.GetPropertyValue("author").ToString() != ""))
{
hasAuthorInfo = true;
}
string author_name = "";
string author_facebook_page = "";
string author_twitter_username = "";
string author_member_profile_url = "";
if (hasAuthorInfo)
{
var author = Members.GetById((int)Model.Content.GetPropertyValue("author"));
author_name = author.Name;
author_facebook_page = author.GetPropertyValue("facebookProfilePage").ToString();
author_twitter_username = author.GetPropertyValue("twitterUserName").ToString();
author_member_profile_url = author.GetPropertyValue("memberProfileUrl").ToString();
}
// FEATURED IMAGE
// Check if there is a featured image for this page
bool hasFeaturedImage = false;
string page_featuredimage_url = "";
if (Model.Content.HasProperty("featuredImage") && (Model.Content.GetPropertyValue<int>("featuredImage") != 0))
{
hasFeaturedImage = true;
}
if (hasFeaturedImage)
{
var image = Umbraco.TypedMedia(Model.Content.GetPropertyValue("featuredImage").ToString());
page_featuredimage_url = domain + image.GetCropUrl("1200x630"); // Preferred size by Facebook
}
}
<meta name="description" content="@page_description" />
<meta property="og:title" content="@page_title" />
<meta property="og:site_name" content="@site_name" />
<meta property="og:url" content="@page_url" />
<meta property="og:description" content="@page_description" />
<meta property="og:image" content="@page_featuredimage_url" />
<meta property="fb:app_id" content="@site_fb_app_id" />
<meta property="og:type" content="article" />
<meta property="og:locale" content="nb_NO" />
<meta property="article:author" content="@author_facebook_page" />
<meta property="article:publisher" content="@site_fb_page_url" />
<meta name="twitter:title" content="@page_title" />
<meta name="twitter:description" content="@page_description" />
<meta name="twitter:image:src" content="@page_featuredimage_url" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@site_twitter_username" />
<meta name="twitter:creator" content="@author_twitter_username" />
<script type="application/ld+json">
{
"@@context": "http://schema.org",
"@@type": "NewsArticle",
"mainEntityOfPage":{
"@@type":"WebPage",
"@@id":"@page_url"
},
"headline": "@page_title",
"image": {
"@@type": "ImageObject",
"url": "@page_featuredimage_url",
"height": 630,
"width": 1200
},
"datePublished": "@page_created_date.ToString("o")",
"dateModified": "@page_updated_date.ToString("o")",
"author": {
"@@type": "Person",
"name": "@author_name"
},
"publisher": {
"@@type": "Organization",
"name": "@site_name",
"logo": {
"@@type": "ImageObject",
"url": "@site_logo_url",
"width": "@site_logo_width",
"height": "@site_logo_height"
}
},
"description": "@page_description"
}
</script>
关于seo - 在 MVC 中为 Umbraco 中的 SEO 呈现 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39913062/
我有一个 aspx 应用程序。在每个 GET 中,服务器以包含除表格网格之外的所有内容的“基本”html 进行响应。 这个“网格信息”包含在页面中隐藏的输入类型(json 格式)中。 这是设计使然,无
阅读有关 iOS 中 UIViewControllers 更改的文档,我试图弄清楚呈现模态视图 Controller 之间的交互如何在自定义容器 View Controller 内工作。最终,我希望能
我正忙于编写自己的 JSF2 UIComponent 及其相关的渲染器。我所有的 UIComponent 都实现了 ClientBehaviorHolder。我不明白的是如何真正呈现 ClientBe
我正在开发一个使用UIPopoverController的应用程序,我在呈现该弹出窗口时遇到问题,我有一个添加在self.view上的UIView,并在该 View 上添加了一个表格 View ,该表
我有一个简单的应用程序,我想在用户首次登录应用程序时在其中显示一个 PageViewController。他们查看教程后,在下一次加载时不会显示 PageViewController。 但是我收到了以
我正在尝试制作一个小型的backbone.js 应用程序,但在事情的顺序上很挣扎。 在我的 html 文件中,标题中有两个脚本 block : jQuery(function(){
我有一个以模型为来源的表格: $form->setModel("test"); 在模型中,我们可以定义字段类型,例如:boolean 将在表单中制作复选框。 现在我们如何定义呈现为单选按钮的类型? 最
fabricJS 版本 2.2.3 测试 jsFiddle 我正在尝试使用 LabeledRect 子类,但我的问题是,每当我尝试从 JSON 加载它时,它都不会呈现,并且在控制台中也没有出现错误。请
在我的 Xaml 中,我定义了一个资源作为 vehicleDataInput,它提供一些文本框供用户输入数据。如果我没有为它定义一个 x:Key ,它将在我的应用程序中出现并按其应有的方式工作。问题是
我在 React 中创建了一个 Symbol 组件来轻松呈现 HTML Symbols像 euro 这样的名字将呈现 €(€) 或 sum 呈现 ∑(∑). 问题是,如果我只渲染 HTML 代码,我将
我尝试渲染一个 View ,该 View 工作正常,但似乎无法获得传递给它的模型对象。我不知道原因,因为根据所有手册和示例,这应该非常简单。 模型对象 class Race { def dis
我正在尝试为Grails项目添加一个简单功能,类似于youtube,它将允许用户喜欢/不喜欢文章。有一个非常原始的页面来显示带有喜欢的文章和一个使“喜欢”成为可能的 Controller 。 las,
我的应用程序中的第一个 ViewController 子类 UIImagePickerController 然后通过 didFinishPickingMediaWithInfo 回调,我执行以下操作:
我正在做一个简单的 redux/react todo 应用程序。我无法显示待办事项。我能够 console.log 数据,但无法显示它。我做错了什么? 我把文件分开了,这是我的app.js: impo
我正在尝试呈现一个导航 Controller ,它似乎可以工作并呈现导航 Controller 。但是,即使它有效,我仍然不断收到错误? 我的代码 let vc = storyboard.instan
我正在重新创建一个简单版本的 snapchat 应用程序,但遇到了一个恼人的小问题,我似乎无法找到解决办法。 我查看了一些答案,例如 this one但没有运气。 总体概念与 snapchat 用户单
我在呈现警报时遇到问题。我正在使用 UIAlertController。当用户按下提交按钮时,在应用程序执行某些操作时,需要立即显示“请稍候..”的警报。操作完成后,警报将消失。尽管应该在我开始执行操
我只是想用 Kinetic 渲染图像,但没有出现,也没有出现错误。 可以找到 fiddle here . 源代码: $( function() { var stage = new Kineti
我正在使用 Phantomjs 检查我的应用程序。我正在查看的页面包含很多组件,并且由 Angularjs 提供支持。我的测试服务器很慢。在 onLoadFinished 事件中,我使用渲染对网页进行
我有一个变量,它的字符串包含我所有的文档,如下所示: var string = " ReportHelloWorld"; 我想打开一个正确插入和显示此报告的新页面,但不知道如何操作。我该怎么办? 感谢
我是一名优秀的程序员,十分优秀!