Joomla CMS creates SEO-friendly URLs with help of menu links. This simple lesson should be kept in mind at all times when creating a Joomla website.
If we want to have uniform URLs, we need to know which menu links to create and which not to create. The basic rules are:
1) Don't create multiple menu link items in one tree line
2) Create menu links at the highest tree level
We will explain everything on the Phoca Cart component, where it is possible to create multiple views, even in a single tree.
Don't create multiple menu link items in one tree line
The following tree of views can be found in Phoca Cart:
Categories View - Category View - Product View
In words: We will create a menu item on Categories view where user can see all categories, using links in frontend he/she can navigate to a specific category and again using links he/she can navigate to a particular product. So he/she navigates from Categories view to Category view and then to Product View and back.
If we create one menu link to Categories view, everything is fine. Joomla creates one SEO-friendly URL format and uses that at all levels. But the problem occurs if we create both a menu link to Categories view and to Category view for example. Then a different URL format is created for each level and the SEO-friendly URLs are inconsistent.
Example:
- menu link to Categories view with "shop-categories" alias created
- menu link to Category view with "shop-category" alias created
In such case the URL format changes when user navigates from Categories view to Category View:
www-your-site-com/shop-categories (Categories view) -> www-your-site-com/shop-category (Category view) -> www-your-site-com/shop-category/productname (Product view)
If only one menu link to Categories view will be created (e.g. with alias "shop"), then you get following format:
www-your-site-com/shop (Categories view) -> www-your-site-com/shop/categoryname (Category view) -> www-your-site-com/shop/categoryname/productname (Product view)
This means that the SEO-friendly URL format remains stable and unique.
Therefore, if possible, always create only one menu link for items in one tree.
But what to do if you have, for example, a menu link to Categories view and you need to make a menu link to a specific category as well?
In this case, don't create a new menu item, but navigate from Categories view to Category view in the frontend and copy the automatically created SEO-friendly URL. Then, in the menu link, create a menu link of type: System Links - URL and paste this static "absolute" URL there.
Create menu links at the highest tree level
If at all possible, always create a menu link at the highest level - usually a list of categories. This is very important, because then all links within that extension will create unique SEO-friendly URL format. If you don't create a top-level menu link, other links that are looking for their parent menu items will not be able to find such items and will not create right SEO-Friendly URL.
What about other menu links that are not in the tree?
In Phoca Cart, these can be, for example, links to Checkout view or User Account view and so on. These links do not belong in the main link tree (Categories view - Category view - Product view). Therefore it is not a problem to create your own menu items for these links. Here there is no need to create the URL uniformity that is required for the main link tree.