• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Canonical links


Well-known member
So, say I have


I want to make this:

I think XenForo calls this canonical requests. How exactly is this feature used? I looked at the thread and forum controllers and tried to see how it works there, but it didn't explain much.

As always, any help is appreciated :)

Jake B.

Well-known member
It's handled in the route in the buildLink method. If you use XenForo_Link::buildBasicLinkWithIntegerParam you'd just set whatever the title field is (In most default XF things such as conversations and threads it is 'title') as the 6th parameter. Here's what XenForo uses for conversations, and is the most basic example:

    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
        $action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
        return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'conversation_id', 'title');


Well-known member
If you are talking about how XenForo canonicalizes links such as this:




(or utilizing the proper title) when loading the links, you want to look at and utilize the following functions in your controller action:
XenForo_Controller::canonicalizeRequestUrl($linkUrl) (takes the response from XenForo_Link::buildPublicLink()) and
XenForo_Controller::canonicalizePageNumber($page, $perPage, $total, $linkType, $linkData = null)

Example from the threads controller:
        $this->canonicalizePageNumber($page, $postsPerPage, $thread['reply_count'] + 1, 'threads', $thread);
            XenForo_Link::buildPublicLink('threads', $thread, array('page' => $page))