Currently, there are no extensions for Joomla that add a canonical link to your pages. However, you can easily add that link to your home page.
To add a canonical link to your Joomla home page
Note: This procedure requires that you edit your Joomla template.
- Download the template file that contains the html <head> information and open it with a text editor. The main template file is usually in /templates/your-template/index.php. However, if you are using a Joomla template framework such as Yootheme Warp or RocketTheme Gantry, you need read the documentation for editing framework files.For YooTheme Warp, you can find the file in /templates/yoo-template/template.phpNote: If you modify a core framework file, your changes will be overwritten if you install a framework or template update. With YooTheme Warp, you can create your own style and copy the template file there. See Warp documentation for details.
- Somewhere between the opening and closing <head> tag, add the following code:
<?php $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault()) { ?> <link rel="canonical" href="http://mysite.com" /> <?php } ?>
Note: this code tells Joomla to determine if the page displayed is the home page. If it is, then it inserts the canonical link. If it’s not the home page, then no canonical link gets displayed.
Pages: Page 1 Page 2
Jordan D. says
@Pat Fortino “Currently, there are no extensions for Joomla that add a canonical link to your pages”
This isn’t true. I’ve been using a canonicalization app on all of my Joomla 2.5 sites for at least the last year. Further, a quick Google search returns two different extensions, at least.
This one has 4.94/5.0
http://extensions.joomla.org/extensions/site-management/seo-a-metadata/url-canonicalization-/5355
Here’s another one for multi-language sites:
http://extensions.joomla.org/extensions/site-management/seo-a-metadata/url-canonicalization-/19802
Pat Fortino says
I’m not talking about domain name canonization. I’m talking about the canonical url that needs to be written on each unique page so you can avoid duplicate content. There are no joomla extensions that do this.
Jordan D. says
I don’t know man… There’s a category of extension called “URL Canonicalization.”
index.php?option=com_content&view=article&id=199:dispatch-monitor-and-report&catid=64:field-service-management&Itemid=498
I spot checked one of the sites I run, http://www.morphisinc.com, by clicking on random links in the top menu and then viewing the page source. All of them had rel=canonical with the appropriate URL.
What I wasn’t able to find was a non-canonical version of a page that didn’t redirect to a canonical version, but I thought about it and I didn’t see how the extension would accomplish this given the information it was given. I suspect that it just puts the tag on every page which kind of janky.
I like your fix though. Do you know of any reason why one wouldn’t be able to make an extension based on this fix?
Pat Fortino says
I think you can use a sef extension like sh404sef to write cannonical urls for each page, but there are no extensions that do it automatically. Having to write each one manually would be a major pain if you have 100s of pages.
Andy says
Ich habe unter http://stackoverflow.com/questions/14147627/get-active-menu-url/14171745? eine Frage nach einer ein wenig erweiterten Version eröffnet. Eventuell hat hier jemand eine Idee?
calvin says
I dont want this on just my home page – your solution only works for that.
If a age is internal say site.com/page1
then I would like the code to be
canonurl=site.com/section1/page1
even if the page is found by inserting ignored junk (like crawling seems able to do)
site.com/I-am-ignored-junk/section1/page1
I still want the same canon url to be displayed as
!!!!!!! canonurl=site.com/section1/page1 !!!!!!!
, but what is the joomla framework php that will give me the right URL !