简体   繁体   English

规范网址的用法

[英]Usage of canonical URL

I am trying to set up og tags in order to share my sub-page on Facebook. 我正在尝试设置og标签,以便在Facebook上共享我的子页面。

My subpage's URL is : www.example.com/subpage.html 我的子页面的URL是:www.example.com/subpage.html

The code for Facebook: Facebook的代码:

<meta property="og:title" content="some text">
<meta property="og:type" content="website">
<meta property="og:url" content="http://www.example.com/subpage.html">
<meta property="og:image" content="www.example.com/subpage.html/images/image1.jpg">
<meta property="og:site_name" content="some text">
<meta property="og:description" content="some text">
<meta property="og:image:width" content="470">
<meta property="og:image:height" content="246">

I am also using a canonical url which is : 我还使用了一个规范网址:

<link href="http://www.example.com" rel="canonical">

So my question is: Should be property="og:url" the same with the canonical? 所以我的问题是:property =“ og:url”是否与规范相同? If I test it on Facebook URL debugger as it is (above) then it will fetch the correct information. 如果我按上面的方法在Facebook URL调试器上对其进行测试,则它将获取正确的信息。 But it gives me the following warning: 但这给了我以下警告:

Mismatch og:url and canonical url og:url tag in the header is not the same URL as rel='canonical' link in the html. 标头中的og:url和规范url og:url标签不匹配,它与html中的rel ='canonical'链接的URL不同。

If I change it and make it the same with the canonical then instead of information that was intended for the subpage it will fetch info that was intended for my homepage which is something that I don't want. 如果我更改它并使其与规范相同,那么它将代替原本用于子页面的信息,而不是原本用于子页面的信息,这是我所不希望的。

So do I have to leave it as it is? 那么我是否必须保留原样?

The debugger is simply following the conventions. 调试器仅遵循约定。 The canonical url shouldn't be pointing to other pages unless they share the same content. 规范网址不应指向其他页面,除非它们共享相同的内容。 Well, I'm oversimplifying it. 好吧,我简化了。

There are many sources online you can read about this. 您可以在线阅读许多资源。 For example this article. 例如这篇文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM