Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Canonical Links

422422 MVP
edited July 2012 in Vanilla 2.0 - 2.8

So I am testing out a small code snippet I made for a site we are developing, I am not really big on SEO. Have read quite a bit, but the whole canonical link tag .. confuses me. So thought I would shove it on this new site and see what the results are , if any etc etc.

So If you would like to add a canonical link ( dynamic ) version to your website or forum. Paste this code into your head section. Page in this instance must be a .php

For vanilla, add it to your default.master.php

<link rel="canonical" href="<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];echo $url;?>"/>

Further reading: here

Save the above code, refresh your forum page, and inspect the src code.

I dont know if its of any use, but thought I would share !

Regards

There was an error rendering this rich post.

Tagged:

Comments

  • ToddTodd Vanilla Staff

    We already put a canonical url in the head. The idea is not to just echo back the current url, but to have code that generates the one true (i.e. canonical) url for any given url.

    Have a look at the source of the following pages:

    http://vanillaforums.org/discussion/20855/canonical-links
    http://vanillaforums.org/discussion/20855/canonical-links?foo=bar
    http://vanillaforums.org/discussion/20855/canonical-what

  • Can you tell me why the page number is part of the Canonical URL?

    In my opinion, there is no need for that because:

    1. if I change the number of comments on a page after indexing, the index will be misleading.

    2. a good redirection is available in Vanilla: you are redirected to the last comment item if you run the address without a page number in URL.

    ( mysite.com/discussion/mydiscussionname -> mysite.com/discussion/mydiscussionname#itemXY )

    So, why isn't the Canonical URL sg. like "mysite.com/discussion/mydiscussionname" ?

  • this is a good and valid question, however if one were to do this then search engines would likely not index most of the content on your site, since i dont believe they append but rather replace any indexed results for a given canonical url.

    also, if you performed a search and the result was a specific post on page 15 of a discussion, by indexing only a generic link to the discussion, the search engine would never be able to actually take the user to the requested content.

  • This one is already built-in on 2.1.

  • @fr3333333x said:
    This one is already built-in on 2.1.

    What exactly is already bulit-in? 2.1 is not available yet, is it?

  • @Casbbencs canonical links is already available on vanilla 2.1, you can find vanilla2.1 in GitHub but it's not actually released yet since it's still on development phase

  • @fr3333333x said:
    Casbbencs canonical links is already available on vanilla 2.1, you can find vanilla2.1 in GitHub but it's not actually released yet since it's still on development phase

    Of course, I know it is included, in my original question I asked about why it is generated the way it is.

    @hbf said:
    this is a good and valid question, however if one were to do this then search engines would likely not index most of the content on your site, since i dont believe they append but rather replace any indexed results for a given canonical url.

    I'm not a SEO expert, I dont't fully understand yet how Canonical URLs should work from the inventors' point of view.

    also, if you performed a search and the result was a specific post on page 15 of a discussion, by indexing only a generic link to the discussion, the search engine would never be able to actually take the user to the requested content.

    But from Vanilla point of view I think it should work like:

    - index for a single discussion:
    "mysite.com/discussion/mydiscussionname"

    - index for a specific post:
    "mysite.com/discussion/mydiscussionname#itemXY"
    or
    "mysite.com/discussion/comment/CommentNumber/#Comment_CommentNumber"

  • @fr3333333x said:
    Casbbencs canonical links is already available on vanilla 2.1, you can find vanilla2.1 in GitHub but it's not actually released yet since it's still on development phase

    canonical link headers are part of 2.0..... no need to try deploying beta code.

Sign In or Register to comment.