02/04/2025
Bismillah...
Today, we will learn how to create SEF URLs for a custom Joomla component, similar to WordPress. Here’s a quick and effective method without needing router.php.
Example SEF URL:
http://localhost/joomla_demo/en/joomla-web-development
Steps to Create SEF URLs:
1. Create a Menu Item:
- Go to the Joomla admin panel and create a menu item for each course.
- You can create this inside the Tarbiat LMS menu or the main menu.
- Set "Display in Menu" to "No" to keep it hidden.
2. Fetch the Itemid in default.php:
- In your component’s default.php file, loop through items like this:
foreach ($this->items as $i => $item) :
- Get the course menu using a helper function:
$coursemenu = coursemenuFromJoomlaMenu($item->id);
- Match the course database ID with the menu parameter course and get the Itemid.
3. Generate the SEF URL:
- Pass the Itemid into the URL, which will generate a clean SEF URL like /joomla-course.
4. Make Google Aware of Your SEF URLs:
- Submit your updated sitemap to Google Search Console.
- Use the "URL Inspection" tool in Search Console to request indexing.
- Ensure your robots.txt allows crawling of your component.
- Add metadata and use relevant keywords for better SEO.
Watch the tutorial for a detailed walkthrough: [How to Create SEF URL for Custom Component](https://youtu.be/TtsMUqDmdUw)
And that’s it! You’ve created SEF URLs for your custom component without the need for router.php. Simple and effective!