One of the coolest features of Joomla 1.5 is the built in Search Engine Friendly URLs (SEFs). No longer do your URLs have to look like:
http://www.example.com/index.php?option=com_content&view=article&id=19&Itemid=27
But instead can look nice and clean like:
http://www.examples.com/about-us
(Actually, calling this a feature is probably a bit of a misnomer. The ability to have clean and controllable URLs is absolutely essential. Especially for content heavy sites that Joomla is often used for.)
Turning on SEFs is easy enough. Though, figuring out how to access content, and control the SEF in use, was surprisingly tricky. Below is what I've pieced together as to how this all works - which means I could be way off base here. But, from poking around, this is what I've figured out.
Finding The Content URL
I got hung up early in the process -- suppose I just finished authoring the About Us page for the site. What's the SEF url to this page? It's a simple question, but I was stumped on it for longer than I'd like to admit.
I tried guessing at this, and no matter what I tried, I came up with a 404 URL. Finally, Jomo over at Jomo Design gave me a wonderfully simple solution to this problem. To find the URL for a piece of content, just search for it using the Joomla's built in search function. The result will contain the URL to the content item.
And, as expected it worked perfectly. The only surprise was the URL that I found. The URL had the shape:
http://www.example.com/component/content/article/26-info/225-about-us.html
That's kinda-sorta a SEF URL in that text is locate in there -- but what the heck is up with component/content/article? And why are the IDs prepended to the category and content name?
If this was Joomla's idea of a SEF URL, then we were going to have serious issues.
Real SEF URLs
As I poked around the site further, I realized that some content items did actually have clean SEF URLs. And then I realized why -- items included in a menu had their URL controlled by the alias on the menu.
So, if I added the About Us page to the site's main menu, and gave the menu item the alias about-us, my URL was exactly as expected:
http://www.example.com/about-us
Nested menus allowed for nested URLs.
This menu based URL approach actually makes a fair amount of sense, as menus in Joomla are way more than a navigational convenience. They are used to drive the functionality of a particularly rendered page. Making them them the controller of SEF URLs was actually a good thing.
The URL addressing scheme I found when I searched for content was probably never intended to be exposed to the user.
Linking To Content Not Found On A Menu
OK, so menu's drive the SEF URL. But, what if you want to have a page included in your site that doesn't belong on a menu? Say you've got a page that shows Search Results that you'd like the URL to be:
http://www.example.com/results
However, you don't want to add the results page to a menu that people can directly navigate to.
I didn't find a Joomla recommendation to this problem -- though I did find a solution.
The answer? Create a new menu, and add the items there. The new menu, created out of the ether, won't be linked to the URL in any way. However, that doesn't diminish its ability to function as a SEF entry point.
In my case, I created a menu named direct-access, and linked all the pages that I wanted to have SEF URLs, but didn't want them to appear to users to browse through.
Problem Solved or Point Missed?
Part of me wonders if I'm totally missing the point of Joomla SEF URLs and I've invented a work around to a problem that shouldn't exist. But for now, the strategy is working. If you've got a better suggestion -- I'd love to hear it.
No comments:
Post a Comment