How to add "noindex" tag to a specific post/page

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
hyaena_swine
Registered User
Posts: 3
Joined: Mon Aug 14, 2017 8:48 am

How to add "noindex" tag to a specific post/page

Post by hyaena_swine »

Hi!

I am running v3.1.9.

What I want to do is make one specific forum post as 'noindex' for Google.

In other words, I need to add this code

<meta name="robots" content="noindex, nofollow">

To the head html of one forum post only.

The rest of the forum is just fine. Simply put, for reasons I won't go into, there is one particularly sensitive post on the forum that I don't want to be indexed in Google. I know I could just delete the post, but I would rather not do that.

The page itself is in the format:

http://www.sitedomain.com/forum/viewtop ... 10&t=18710

So, how can I do that? :)

Thanks!
User avatar
janus_zonstraal
Registered User
Posts: 6617
Joined: Sat Aug 30, 2014 1:30 pm

Re: How to add "noindex" tag to a specific post/page

Post by janus_zonstraal »

Block that forum for bots is the only option.
ACP=> permisions => forum permissions => select "bots" and "forum" => set to "no "
Sorry! My English is bat ;) !!!
hyaena_swine
Registered User
Posts: 3
Joined: Mon Aug 14, 2017 8:48 am

Re: How to add "noindex" tag to a specific post/page

Post by hyaena_swine »

Thanks... but this will block indexing of the ENTIRE forum, which is NOT an option for this case.

Any other creative hack that can provide a solution ?
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: How to add "noindex" tag to a specific post/page

Post by david63 »

Put it in its own forum with no bot access.

If the post is already on your board then it is probably too late anyway as the bots will have already found it.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
_Vinny_
Style Customisations
Style Customisations
Posts: 10475
Joined: Tue Aug 11, 2009 12:45 am
Location: Brazil
Name: Marcus Vinicius

Re: How to add "noindex" tag to a specific post/page

Post by _Vinny_ »

You can try this code:

Code: Select all

<!-- IF S_TOPIC_ID == '18710' -->
<meta name="robots" content="noindex, nofollow">
<!-- ENDIF -->
18710 is topic ID. Add this code before </head> in styles/template/overall_header.html. Or you can create a simple extension to prevent file editing
hyaena_swine
Registered User
Posts: 3
Joined: Mon Aug 14, 2017 8:48 am

Re: How to add "noindex" tag to a specific post/page

Post by hyaena_swine »

Thanks Vinny - I will give that a try!!

Excuse what may seem a silly question, but I notice the IF statements are wrapped in 'comments'. Should I remove those if I am injecting it into the html file ?

Cheers! :)
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: How to add "noindex" tag to a specific post/page

Post by david63 »

hyaena_swine wrote: Mon Aug 21, 2017 10:11 am Excuse what may seem a silly question, but I notice the IF statements are wrapped in 'comments'. Should I remove those if I am injecting it into the html file ?
No - that is phpBB template syntax
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
_Vinny_
Style Customisations
Style Customisations
Posts: 10475
Joined: Tue Aug 11, 2009 12:45 am
Location: Brazil
Name: Marcus Vinicius

Re: How to add "noindex" tag to a specific post/page

Post by _Vinny_ »

Complementing what david posted:

This is the phpBB Template syntax. This will basically make the code executable only if the topic ID is 18710.

Return to “phpBB Custom Coding”