0
<meta content='noindex' name='robots'/>
<meta content='noarchive' name='robots'/>
<meta content='nofollow' name='robots'/>

在页面上<head>,如何在带有问号 ( ? ) 的永久链接页面上显示元标记。

永久链接示例:

  • http://mydomain/blablahhblaa(将出现在此永久链接页面上 <head>
  • http://mydomain/blablahh?bla不会出现在这个永久链接页面上 <head>

信息 1:平台:Blogger/Blogspot

INFO 2:默认情况下,在 Blogspot 博客平台上,要显示/隐藏某些永久链接中的内容,只需使用以下代码:

<b:if cond='data:blog.pageType == &quot;http://THEPERMALINK.COM/BLABLA&quot;'>

Content at this space will appear at this permalink http://THEPERMALINK.COM/BLABLA

<b:else/>

Content at this space will appear at all pages exclude this permalink http://THEPERMALINK.COM/BLABLA

</b:if>

INFO 3:要在 Blogspot 博客平台中获取当前 URL,使用此代码:data:blog.url<data:blog.url/>

这里的重点:我想尝试做类似下面的事情Shortcut_For_Any_Permalink_Have_a_Question_Mark

<b:if cond='data:blog.url == &quot;Shortcut_For_Any_Permalink_Have_a_Question_Mark&quot;'>
<meta content='noindex' name='robots'/>
<meta content='noarchive' name='robots'/>
<meta content='nofollow' name='robots'/>
</b:if>

非常感谢。

4

1 回答 1

0

好吧,我会说你应该使用你的 javascript 来检查是否有任何 URL 参数集(问号后面的任何内容),如下所示:

注意:这是未经测试且可能无法正常工作的代码。这只是为了说明这个概念。

$.urlParam = function(name){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
    return results[1] || 0;
}

// example.com?param1=name
var param = $.urlParam('param1'); // name

if (param)
{
    // execute code
}

然后,如果设置了任何参数,您可以让 JS 写入元行。

所以默认情况下没有 robots 元标签,如果设置了任何参数,JS 会将它们写入 head 标签。

于 2013-10-23T18:37:14.363 回答