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.

Vanilla shows wrong canonical URL for categories?

edited March 2012 in Vanilla 2.0 - 2.8

The canonical URL for categories is broken. It shows the same canonical URL: http://forum.example.com/categories or http://example.com/forum/categories — for all categories!

Besides that page doesn't exist — it gives a 404 error.

Is this a bug? How can this be fixed? Hope someone can chip in. Thanks.

@Todd ?

Best Answers

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    This is a bug that has been fixed in our dev branch. I'll get it back ported to the 2.0.18 branch.

  • lucluc ✭✭
    Answer ✓

    Might be this one:

    Fixed canonical url in /categories/*.
    https://github.com/vanillaforums/Garden/commit/c9d97264f060f246c411c649f71fa512af136516

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    Excellent find. I cherry-picked that commit into the 2.0.18 branch.

  • lucluc ✭✭
    Answer ✓

    Not sure.

    I might just do it soon for myself, but that's just a forum for me and my wife.
    But that's not something that anybody could recommend.

    I guess, it does work most of the time as vf.org is running at least most of it.

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    2.1 has a lot of changes and we have a lot of backwards-compatibility with theming right now. If you don't know what you are doing then don't go unstable.

    With regards to the canonical url thing. I may take out that if statement since it can't hurt, but for now don't worry about the canonical url not being there. The purpose of the canonical url is to remove ambiguity between two of the same page on different urls.

«1

Answers

  • UnderDogUnderDog MVP
    edited March 2012

    DUDE! You only posted this question a couple of hours ago and now you want already attention from a specific person?

    Let your question live in the discussion list for a while! After you haven't gotten any response for a couple of days, THEN ask a specific person.

    And the first response for you is (abacadabra):

    Learn how to SEARCH in the forums!

    (then also search for forum etiquette, there's a whole thread about it)

    There was an error rendering this rich post.

  • edited March 2012

    @UnderDog :

    1. Calm down.

    2. First I searched. I couldn't find any solution.

    3. I posted my question. As always, I started searching for a solution again.

      • came across a thread reporting the same issue, but there were no replies.
      • Saw some other thread, where the user believed it to be a bug, and @mentioned Todd. He jumped in solved the issue once for all.

    So, as it should have been obvious by now, your analysis is pure bullsh!t. So stop judging and try to help. This is a community. You are a moderator, and that doesn't mean... well, you should have realized it by now.

    And if you actually know that 'there's a whole thread about it', as a moderator didn't you have the minimum courtesy to share the link? Damn, you have made my day!

    One suggestion: maintain a friendly tone with others. Ones asking a question here need help, not your silly judgements. :)

  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    I second @badlearner 's opinion.

    There was an error rendering this rich post.

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    This is a bug that has been fixed in our dev branch. I'll get it back ported to the 2.0.18 branch.

  • @Todd : If there's a file (on GitHub) that I can refer to for changes, it would be very helpful. I will gladly post the fix here for everyone.

  • lucluc ✭✭
    Answer ✓

    Might be this one:

    Fixed canonical url in /categories/*.
    https://github.com/vanillaforums/Garden/commit/c9d97264f060f246c411c649f71fa512af136516

  • ToddTodd Chief Product Officer Vanilla Staff
    Answer ✓

    Excellent find. I cherry-picked that commit into the 2.0.18 branch.

  • Thanks Todd and Luc!

  • ToddTodd Chief Product Officer Vanilla Staff

    And as an fyi @badlearner, Any canonical urls that are specifically overridden will always be in the controllers with a call to $this->CanonicalUrl(...).

  • Yes, got it. Thank you.

  • edited March 2012

    @Todd : Did you push the entire file or just that line? Here's the thing:

    Using the entire file causes this error on Vanilla 2.0.18.3:

    Fatal error: Call to undefined method Gdn_Theme::Section() in /home/xxx/public_html/forum/applications/vanilla/controllers/class.categoriescontroller.php on line 220
    

    In another scenario...

    Adding this line (replacing the existing one):

    $this->CanonicalUrl(Url(ConcatSep('/', 'categories/'.GetValue('UrlCode', $Category, $CategoryIdentifier), PageNumber($Offset, $Limit, TRUE, FALSE)), TRUE));
    

    And removing this:

    $this->CanonicalUrl(Url('/categories', TRUE));
    

    Completely removes the canonical meta tag from the source. So, in a way, there's no fix yet (unless I am doing something seriously wrong). Thought I should let you know.

    EDIT: Using the file you just pushed on GitHub gives an error (see above).

  • @badlearner, have you had any success this is the same problem I have.

    Is this pretty much the solution.

    `Adding this line (replacing the existing one):

    $this->CanonicalUrl(Url(ConcatSep('/', 'categories/'.GetValue('UrlCode', $Category, $CategoryIdentifier), PageNumber($Offset, $Limit, TRUE, FALSE)), TRUE));`
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine : As you can see I have pinged @Todd about it, and he hasn't replied yet. And no adding that line alone doesn't seem to fix anything.

    I believe that the changes made in that file (/vanilla-root/applications/vanilla/controllers/class.categoriescontroller.php) are streamlined to work with Vanilla 2.1*, and apparently, not Vanilla's current stable v2.0.18.3. :(

    So, yeah I am waiting for a fix too.

  • ToddTodd Chief Product Officer Vanilla Staff

    Did you remove the second call to Canonical Url? I tested and pushed that very fix in the 2.0.18 branch.

  • @Todd : Oh yes, I did. Please see this comment of mine, you'll see exactly what I did.

  • ToddTodd Chief Product Officer Vanilla Staff

    Okay I think I know what's happening here. When the canonical url matches the current url then it doesn't show up. Canonical urls only show up when there's a difference.

  • Todd said:
    Okay I think I know what's happening here. When the canonical url matches the current url then it doesn't show up. Canonical urls only show up when there's a difference.

    But canonical URLs are supposed to show up in the source of every page right?

    In a similar instance, Lincoln said that the issue of breadcrumbs not showing up in a theme has been fixed in v2.1. He also referred me to a file. But when I made the changes on my Vanilla v2.0.18.3 forum, breadcrumbs weren't still showing up.

  • lucluc ✭✭

    Todd just told you if the canonical is the same as the url it's served from, it doesn't show up.

    This one was tested.
    Otherwise, you can expect any changes from the upcoming 2.1 to be work, some are linked to other changes in the code too.

  • edited March 2012

    @luc : One last question - - do you think it's a good idea to start my public-facing forum using the unstable master version? I am willing to update my theme everyday with the latest changes.

    The thing is, Vanilla 2.0.18.3 has too many issues (at least for me) to use it. Just looking for some advise here.

  • lucluc ✭✭
    Answer ✓

    Not sure.

    I might just do it soon for myself, but that's just a forum for me and my wife.
    But that's not something that anybody could recommend.

    I guess, it does work most of the time as vf.org is running at least most of it.

This discussion has been closed.