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

On pages <head>, How to show meta tags above only on permalink pages that have a question mark symbol (?).

Example permalink:

  • http://mydomain/blablahhblaa (will appear on this permalink page <head>)
  • http://mydomain/blablahh?bla (will not Appear on this permalink page <head>)

INFO 1: Platform: Blogger/Blogspot

INFO 2:By Default on Blogspot blog platform, to show/hide content in certain permalink, just use code below:

<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: And to get current URL in Blogspot blog platform, is using this code: data:blog.url or <data:blog.url/>

The point here: i want to try do something like below 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>

Thanks a lot.

Kamarul Anuar
  • 312
  • 4
  • 16

1 Answers1

0

Well I would say that you should use your javascript to check if there are any URL parameters set (anything after the question mark) like this:

Note: This is untested and probably nonworking code. This is just to illustrate the concept.

$.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
}

Then you can have JS write the meta lines in if there are any parameters set.

So by default there are no robots meta tags, and the JS will write them into the head tag if any parameters set.

gillytech
  • 3,595
  • 2
  • 27
  • 44