0

我在我的网站上使用 WordPress。要将 AMP 页面添加到我的网站,我使用了官方的 WordPress AMP 插件和另一个名为“AMP for WP”的插件。我已经使用它3个月了。最近,我在从笔记本电脑(非移动设备)搜索 Google 时发现了一个非 AMP 页面。我检查了页面来源,发现 rel-canonical 标记已正确设置为非 AMP 页面。我不知道为什么它会出现在桌面搜索中。

要查看示例谷歌这个“如何更改作者框 gravatar 大小”,你会发现 AMP 页面和非 AMP 页面没有出现。

问题出在哪里?!

4

1 回答 1

0

它很可能是在 Wordpress 环境之外设计的。

我们在 Wordpress 环境之外设计我们的 AMP 页面,并且规范标签就像普通页面一样。

简而言之,我们的 amp 页面是独立的,并且可以在台式机和手机上使用。

那时只需要一个规范标签。(不使用 rel-canonical 标签)

$strCanonicalUrl ="https://" . $_SERVER['HTTP_HOST'] . parse_url( 
$_SERVER['REQUEST_URI'], PHP_URL_PATH );

...

<title >This is the title of the AMP page</title>
<meta name="description" content="This is the description of the AMP page">
<link rel="canonical" href="<?= $strCanonicalUrl ?>" />
<meta property="og:locale" content="en_US" />
于 2017-04-11T15:47:55.067 回答