XF 2.1 remove noIndexed Threads from the Sitemap

Out of the box it is not possible to noindex Threads.

Though it could be done manually (via modifications to either PAGE_CONTAINER or smth. like that), it would make more sense to use an Add-on for this, this way threads could also be excluded form the sitemap.

We've implemented this (and other features like noindex for a whole forum, meta descriptions per node, <title>per node, <h1> per node, extended description text for nodes, meta description per thread, etc.) in a custom SEO Add-on.
 
Out of the box it is not possible to noindex Threads.

Though it could be done manually (via modifications to either PAGE_CONTAINER or smth. like that), it would make more sense to use an Add-on for this, this way threads could also be excluded form the sitemap.

We've implemented this (and other features like noindex for a whole forum, meta descriptions per node, <title>per node, <h1> per node, extended description text for nodes, meta description per thread, etc.) in a custom SEO Add-on.

Yes, I have thought of using a meta noindex on page_container but the conditional invoved for more thana few threads or forums is going to complex. And then get nagged by Google Console for still having them in sitemap.

Does your addon solve the problem of removing them from the site map?
 
Yes, we've got code to handle this. It's actually pretty easy, you just need to add a check to XF\Sitemap\Thread::isIncluded() and return false if you do not want the thread to be included.
 
You need to know in witch conditions/cases did you want a noindex tag.

regarding the cases, you need to add code on the template file ( use "Template modifications" system ).
You can build more complex code but i show you two easy examples.


Ex: adding a noindex tag for all thread in node X

In thread_view
PHP:
<xf:if is="in_array({$forum.node_id}, [list,of,forum,ids)">     
    <xen:container var="$head.robots">
        <meta name="robots" content="noindex, follow" />
    </xen:container>
</xf:if>


Ex: adding a noindex tag for post not having more than one message after 30~31 days .

In post_macros
PHP:
<xf:if is="($xf.time - $post.post_date) >= 2629743 AND {$post.post_id} == {$post.Thread.last_post_id} AND {$post.position} == 0"> 
    <xen:container var="$head.robots">
        <meta name="robots" content="noindex, follow" />
    </xen:container>
</xf:if>
 
Yes, we've got code to handle this. It's actually pretty easy, you just need to add a check to XF\Sitemap\Thread::isIncluded() and return false if you do not want the thread to be included.

Can you please explain for someone with only basic knowledge what this is and how to do it: XF\Sitemap\Thread::isIncluded() Thanks
 
Does that mean so you can't explain???
I've already explained what needs to be done in Post #6.
Of course I could post full prose step by step instructions, but that would basically mean I would build a full Add-on for you; it would just not be packaged as a ready to use ZIP.

I obviously do not want to do this; if you want to built smth. on your own you should start to learn how to build an Add-on. I've posted above which method needs to be extended in order to exclude Threads from sitemap and you also already know the conditions to set noindex meta.
That combined knowledge should be enough to get you started :)
 
Last edited:
Top Bottom