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.

migrated from stackoverflow.com Jul 11 '14 at 11:47

This question came from our site for professional and enthusiast programmers.

  • 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 Jul 8 '14 at 19:23
  • You do realise this might affect your load times and cause the host to break out from internal routing? – Anriëtte Myburgh Oct 27 '15 at 13:18
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

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.

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.

New contributor
Jan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Thanks. I have been on here for years. I googled it, Google says absolute url's doesn't make a difference. But from my 404 logs from some years ago I saw it made a difference on other search engines. – Jan 2 days ago
  • I don't really care about credibility. But for you, I asked Google nicely. google.com/… The first answer was: Google Says Absolute Vs Relative URLs Doesn't Matter For SEO seroundtable.com/google-absolute-vs-relative-urls-26001.html – Jan 21 hours ago
  • This lady is for absolute URL's. moz.com/blog/relative-vs-absolute-urls-whiteboard-friday Google don't care, because they have sorted it out. Other search engines and robots are still struggling with it. You can read about it for months on the internet, or check your 404 logs and see real results. It helped my rankings to change to absolute. – Jan 21 hours ago
  • 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. – mickmackusa 21 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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