HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Make Your Vanilla More SEO Friendly - Adding noindex to Duplicate Pages

aeryaery Gtricks Forum in 2.2 :) ✭✭✭

For whom - Those who use Vanilla Wordpress plugin to use forum for blog comments.

Problem - Whenever a comment is made in blog page, a subsequent and similar forum discussion is automatically made which has same title as blog post. Now both are indexed by Google and creating duplicate content. Example here.

Solution -

Each Vanilla discussion page automatically inserts body class of chosen category. Now if your comment belongs to category blog-comments, then use this code -

<script> if (document.body.classList.contains('Section-Category-blog-comments')) { customMeta=document.createElement('meta'); customMeta.name='robots'; customMeta.content='noindex,follow'; document.getElementsByTagName('head')[0].appendChild(customMeta); } </script>

This will automatically insert no-index in duplicate discussions page.

There was an error rendering this rich post.

Comments

  • Options
    x00x00 MVP
    edited July 2013

    This is not much use to search engine who don't run JavaScript, which is most of them.

    You need to bring the solution to the server side, such as through a themehook or plugin.

    grep is your friend.

  • Options

    You can also do it on the server run level buy url pattern as you want the whole category not to be crawled.

    grep is your friend.

  • Options
    ToddTodd Chief Product Officer Vanilla Staff

    Note that both pages are given the same canonical url.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    edited July 2013

    @x00 Yes, I thought that. We could either use themehooks but them need to carry smarty {$BodyClass}. Or we can use theme views.

    But before implementing this, I did some research and found out that Google bot now runs javascript and then crawl text.

    @Todd I am sorry to say, but both pages (the blog and the discussion comment one) have different canonical urls.

    There was an error rendering this rich post.

  • Options
    x00x00 MVP
    edited July 2013

    But before implementing this, I did some research and found out that Google bot now runs javascript and then crawl text.

    I wouldn't rely on this you have no idea to what extent, what engine they are using. The primary purpose of a crawler is to be efficient. Probably the main reason for running initial code, is to get a good assessment of the what the page is like in really, especially to stop black SEO practices.

    Also they are interested in more content to crawl.

    grep is your friend.

  • Options

    You don't care about the class, you care about what category you are in. The class is secondary.

    grep is your friend.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    @x00 agreed. There is no way one could tell up tp what extent. I am trying to play a safe game here. Its an precautionary measure. Something is better than nothing.

    For the second point, that would require getting into core. unfortunately I am not so comfortable with PHP. JS and CSS is my cup of tee.

    There was an error rendering this rich post.

  • Options
    x00x00 MVP
    edited July 2013

    Something like in class.nofollowthemhooks.php

    <?php if (!defined('APPLICATION')) exit();
    class NofollowThemeHooks extends Gdn_Plugin{
    
      public function DiscussionController_Render_Before($Sender){
         $CategoryID = GetIncomingValue('vanilla_category_id', NULL);
         if(!$CategoryID)
            $CategoryID = GetValue('CategoryID', $Sender);
         if($CategoryID == C('Vanilla.Embed.DefaultCategoryID', 0)){
            $this->NoFollow($Sender);
         }
      }
    
      protected function NoFollow($Sender){
          $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,follow'));
      }
    }
    

    drop it in your theme. It assumes you have set Vanilla.Embed.DefaultCategoryID

    grep is your friend.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    You are superstar.

    Much thanks to you.

    Right now, I am going to play badminton, will try to use theme hook late night.

    PS: Tell me if I can do something for you in return. I can design and write documentation.

    There was an error rendering this rich post.

  • Options

    not right now but maybe at a later date.

    grep is your friend.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    I am back.
    Anytime whenever you want.

    There was an error rendering this rich post.

  • Options
    aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    It worked like a charm.

    Since I knew category id, I hard coded this like -

    if($CategoryID == 9))

    because I was not sure of Vanilla.Embed.DefaultCategoryID

    There was an error rendering this rich post.

  • Options

    Hi All
    Need a small help!

    We are working on a WordPress website and have integrated Vanilla Forum WordPress Plugin. Since it opens in iFrame, is it possible to have SEO compatibility for Forums or make Google Crawl those forums.

    Regards
    Rajat Bansal

  • Options
    x00x00 MVP
    edited March 2014

    @rajat87 said:
    Hi All
    Need a small help!

    We are working on a WordPress website and have integrated Vanilla Forum WordPress Plugin. Since it opens in iFrame, is it possible to have SEO compatibility for Forums or make Google Crawl those forums.

    Regards
    Rajat Bansal

    it is not the ideal, I only use it with clients with private forums where SEO is irrelevant. Better to simply run each standalone, but style them to fit in with the brand.

    9/10 having the respective frameworks run on their own, without embedding or (worse) force loading frameworks or doubling up, is better. Let them do what they do best.

    P. S. next time create a new discussion/question.

    grep is your friend.

Sign In or Register to comment.