XF 1.5 How to disallow crawling complete RM and one Node through robots.txt

Sunka

Well-known member
What to add in robots.txt file to disallow Google and other spiders from crawling complete Resources manager and one complete Category (included all in it)?
Thanks (y)
 

Mike

XenForo developer
Staff member
If you just want to disallow the entire RM, then you can block /resources/. However, if you are trying to block a single category, you can't do this via robots.txt. You would need to modify the resource_view template:

Code:
<xen:if is="{$resource.resource_category_id} == 123">
<xen:container var="$head.noindex"><meta name="robots" content="noindex" /></xen:container>
</xen:if>
(I haven't tested this, so please check the code is being output when you expect.)
 

Sunka

Well-known member
If you just want to disallow the entire RM, then you can block /resources/
To add this into robots.txt
Disallow: /resources/

However, if you are trying to block a single category, you can't do this via robots.txt.
I mean category in forum, not category in Resources manager.
Example:
somepage.com/categories/categoryname.23/
 

Mike

XenForo developer
Staff member
Ah, the concept is similar but a different template/condition. You'd be checking thread_view and acting based on {$forum.node_id} .
 

Sunka

Well-known member
You'd be checking thread_view and acting based on {$forum.node_id} .
If node ID is for example 123
This will be right code:

Code:
<xen:if is="{$forum.node_id} == 123">
<xen:container var="$head.noindex"><meta name="robots" content="noindex" /></xen:container>
</xen:if>
Where to put that code in thread_view template?
 

Sunka

Well-known member
If node ID is for example 123
This will be right code:

Code:
<xen:if is="{$forum.node_id} == 123">
<xen:container var="$head.noindex"><meta name="robots" content="noindex" /></xen:container>
</xen:if>
Where to put that code in thread_view template?
That should be correct. It can go anywhere.
@Mike what will be equivalent for xf2?
 

Jeremy P

Well-known member
HTML:
<xf:if is="{$forum.node_id} == 123">
    <xf:head option="metaNoindex"><meta name="robots" content="noindex" /></xf:head>
</xf:if>
 
Top