2

How can i make all my links in joomla including menu items and article links absolute links and not relative ones? and of course, without hacking the core files.

2
  • 6
    Why would you want to do this? It simply makes life so much harder and if you ever decide to move you site to a new host, you will have to update every link
    – Lodder
    Commented Jul 8, 2014 at 19:23
  • You do realise this might affect your load times and cause the host to break out from internal routing? Commented Oct 27, 2015 at 13:18

3 Answers 3

7

The best way is probably to create a plug-in on the onContentPrepare event which does a search-and-replace on any links.

What is the reason you are wanting to do this, though? You have tagged this SEO, but any argument I have seen for absolute links over relative links would be countered by Joomla's use of the base tag. The rest seems to be all hearsay, and it is bad development practise.

If you are worried about broken links, run a broken link checker. Absolute links are just as likely to break.

3

I know you said you do not want to 'hack the core files' but Joomla comes with all these great module/theme overrides that let you customise their output without loosing these changes each time you run Joomla updates. All you need is an FTP program and a text editor. It does involve customising your theme but the core files are left alone.

Absolute Menu Links

To make all menu links output an absolute url I can show you what worked for myself.

A related question that helped point me in the right direction can be found here: How to make a template overwrite for mod_menu with alternative layouts.

If I want to change how my links are output I can copy the default_component.php to my theme's directory and change it e.g.

copy

/modules/mod_menu/tmpl/default_component.php

to

mytemplate/html/mod_menu/default_component.php

It is easy to change the 3 cases at the bottom for the 3 standard links types.

From here clear your cache and test. You should now have absolute urls in your menu items.

Absolute Article Links

Depending on the size of your site this could be easy or tedious. Ask all content editors to use absolute urls when creating/linking to content. You could use a db utility by NoNumber to search and replace in your database but always remember to take a backup first.

0

The answer to the question. In each menu item under Metadata tag make secure on or off according to your needs. Now you have absolute url's. No hacks, no fuss, no tedious.

To everyone that thinks absolute URL's is not SEO. Google say they prefer it. Other younger search engines will add your relative url to the end of your current page's url. Like http://example.com/my-nice-article/my-other-nice article and get a 404. Guess what, they will think your site is crap and full of broken links.

From my 404 logs from some years ago I saw it made a difference on search engines other than google. This page explains why absolute URL's is better. moz.com/blog/relative-vs-absolute-urls-whiteboard-friday

1
  • Please be generous with your knowledge when you edit your answer. All of this information will be valuable to researchers who want to learn more about seo best practices. After editing, please delete your comments. Commented Nov 14, 2019 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.