721 CHAPTER Making a Site Search Engine Friendly IN THIS CHAPTER Creating search engine friendly URLs Creating custom error pages Working with metadata and page titles I f I build it, they will come — or so goes the old way of thinking. On today’s web that sort of thinking is the recipe for failure. The amount of noise and competition is nothing short of spectacular, and it can easily drown out your site, even if the quality of your content is excellent. If you want to get traffic and you want to be seen, you need to make an effort to create a search engine friendly site and you need to engage in at least some basic search engine optimization. Joomla!, like most content management systems, faces some challenges to create a truly search engine friendly site. You will hear some commentators say that you cannot achieve good search engine optimization (SEO) with a CMS, but that view is not entirely correct. You can create a search engine friendly site; however, you may not achieve the level of optimization that a highly trained SEO specialist can get from a pure HTML web site. That said, given the competitiveness of search marketing these days, your use of a CMS is not likely to be fatal to your SEO goals. Effective site optimization should be only one part of your broader search-marketing campaign. This chapter looks at various SEO techniques that can be applied using only the default Joomla! features. Of course, if you want to do more — and those of you who really want to be competitive must do more — there are numer- ous third-party extensions that can be added to your site to address various SEO issues. Part V: Site Maintenance and Management 722 Creating Search Engine Friendly URLs The default Joomla! system produces messy URLs. A default URL contains query strings and other characters that are hard for humans and search engines to read. Accordingly, the first step of any effort to make Joomla! more search engine friendly is to get rid of the messy URLs and get your system to use search engine friendly (SEF) URLs. What is a search engine friendly URL? Generally speaking, a search engine friendly URL is a human friendly URL. The default Joomla! system produces a URL that looks something like this: http://www.joomla1510.com/index.php?option=com_content&view=article& id=27:the-joomla-community&catid=30:the-community&Itemid=30 This is not search engine friendly because some search engines will choke on the odd characters and query strings. It is also not human friendly because it is long, hard to remember, and even harder to type accurately. URLs like this are even difficult to e-mail because their length often forces a line break and causes people to make mistakes when they cut and paste the URL into their browsers. A better URL would look like this: http://www.joomla1510.com/the-community The URL above is a search engine friendly, and human friendly, URL. These two example URLs are real. They actually point to the same page in the Joomla! sample data, in this case the article entitled “The Joomla! Community.” The first example is the default Joomla! system’s URL formulation for the article; the second example shows what you can achieve by sim- ply enabling the SEF URLs feature in the Joomla! system. The process for enabling SEF URLs depends on the Web server being used on your Web host. SEF URLs are simplest to enable on the Apache web server, but they are dependent upon the mod_ rewrite package being installed and your ability to create a .htaccess file. This is not as hard as it may sound because mod_rewrite is typically installed on most common systems and Joomla! actually bun- dles in the default distro a .htaccess file that is ready to go — all you have to do is rename it. If you are running Apache, all you need to do to enable SEF URLs on your Joomla! site is to follow these steps: 1. Access the files of your Joomla! installation on the server. 2. Find the file htaccess.txt. Create a duplicate of it and rename the new file to .htaccess. You can exit the server; you are done here. Chapter 27: Making a Site Search Engine Friendly 723 Note On some servers, once you rename the file to .htaccess the file disappears in the file structure. (It doesn’t really disappear, the file is still there just “hidden” from the file view.) 3. Log into the admin system of your Joomla! site. The Control Panel loads in your browser. 4. Click on the shortcut icon labeled Global Configuration. The Global Configuration Manager loads in your browser. 5. On the right side of the site page is a section named SEO Settings. Set the option Search Engine Friendly URLs to Yes. 6. Set the option Use Apache mod_rewrite to Yes. 7. Click the Save icon. The system will save your changes and enable SEF URLs. Caution You must use the .htaccess file provided by Joomla! Do not attempt to create your own or modify the file, unless you have experience with this process. Definitely do not try this on a live site without first testing it! If your site is using Microsoft’s IIS web server, instead of the Apache web server, the process is dif- ferent and more involved. Note that the process requires you to install the ISAPI filter on the In the preceding SEF URLs example, the last part of that URL, the-community, is referred to as the alias. It is possible to achieve a degree of control over the alias created by Joomla! Sections, categories, articles, and individual menu items include options to set a specific alias. During the creation or editing of a section, category, article, or menu item you can specify an alias for the sys- tem to use to construct the SEF URL. This is done by typing the string you want to use into the field named Alias. Note that the alias field will only accept lowercase letters, numbers, and the hyphen char- acter; it will not accept spaces, uppercase letters, or unusual characters. If you do not specify an alias, the system will automatically convert the item’s title into an alias. Pay attention when creating aliases in order to avoid creating multiple, conflicting aliases. This is pri- marily an issue where you are setting the alias for an article, and then linking directly to the article from a menu. In this case, the menu item will also have an alias field. You should try to make the article alias and the menu item alias consistent, for simplicity’s sake. Note that where there is a menu item linking directly to an article, the menu item alias will take precedence of a conflicting article alias. Note also that sections and categories have aliases. If you are linking directly into the section or cate- gory list pages, then you will need to pay attention to those aliases, as well. In some cases, use of SEF URLs in Joomla! will result in the creation of duplicate article content. If you are concerned about this and want to avoid it, you must manage closely and carefully the aliases between the articles and the menu items. Creating your own URL aliases Part V: Site Maintenance and Management 724 server. This filter is unlikely to be an option available to you if you are on a shared web host. Accordingly, I have not described the steps here in detail. If you have access to your IIS installa- tion, or you can convince your web host, then it is possible to set up SEF URLs on IIS. To learn more about this process, please see the dedicated page on this topic on the Joomla! documentation site at http://docs.joomla.org/IIS6_and_SEF_URLs_using_Joomla_1.5x. Note The Joomla! SEF URLs functionality is enabled by the plugin named System - SEF. This plugin must be enabled for SEF URLs to work. Although it is enabled by default, if you are having problems, check the Plugin Manager to assure it is enabled in your system. The plugins and the Plugin Manager are discussed in Chapter 19. Creating Custom Error Pages You can create custom pages to handle common errors, such as 404 (page not found) errors. This step is optional, and while it has little direct benefit for search marketing, it is very helpful for your site visitors. It can help keep visitors on your site and can improve the perception that the site is professional and useful. Error pages in Joomla! 1.5.x are handled by this file: /templates/sytem/error.php. You can override the default file copying it to your default template directory and then making your changes on the copy; if there is an error.php file in the active template directory, it will be shown instead of the default system file. If you want to work on the styling of the file, you also need to copy the CSS file, /template/system/css/error.css and move it to your default template directory. Remember to update the error.php file to point to the new location of the CSS. Tip There is a page dedicated to SEO and SEF tips on the Official Joomla! Documentation Web site. Visit http://docs.joomla.org/SEF. Working with Metadata and Page Titles A site’s metadata and page titles also play a role in search engine optimization. Key metadata fields, like the description and keywords fields, are sometimes used by search engine spiders to classify your content and in some cases for the description that is associated with your site in the search results output. Page titles not only appear on the browser for the users, but also are indexed by the search engines and appear in the search results. Chapter 27: Making a Site Search Engine Friendly 725 Setting the metadata Joomla! provides both global and individual article metadata options. The default system does not, unfortunately, provide options for individual component metadata. Global metadata is controlled in the Global Configuration Manager. Article metadata is controlled by the metadata parameters inside the Article Editing dialogue. Cross-Reference See Chapter 4 for more information on Global Configuration Manager, and turn to Chapter 5 to find more on working with article parameters. Note that article metadata overrides and takes precedence over the global metadata. Where meta- data has been specified in the article’s parameters it will appear inside the code for that page, in place of the global metadata. Where no article metadata has been specified, the default global metadata will appear in the page’s code. The default system only supports four metadata fields: l Description l Keywords l Robots l Author If you want to add expanded metadata sets either edit the template files to add additional metadata fields into the head of the template or consider adding a third-party extension that provides this facility. Cross-Reference For a discussion of modifying the default template files, please see Chapter 20. Setting the page titles By default, the value you specify for the title field of an article becomes not only the title you see on the page above the article’s text, but also the resulting web page title. The web page title appears on the title bar of the browser and is also displayed as the page title in the search results of most of the popular search engines, including Google. Many search engine specialists believe that the page title has a direct impact on the site’s search engine effectiveness. Unfortunately, the default Joomla! configuration does not give you much flex- ibility. Page titles are generated dynamically, so it is not possible to specify a consistent value for them, absent hacking the core files, as noted later in this section. Moreover, displaying the same value for the title of the text and for the title of the resulting web page may restrict your ability to create optimal page titles that are in line with your search marketing efforts. Part V: Site Maintenance and Management 726 You can use a work-around for this problem. Doing so requires the creation of menu items in which you specify and override the default Page Title display function. It works like this: Where a menu item is used to link to an article, you can specify the page title in the menu item’s system parameters. The page title value in that menu item parameter will take pre- cedence over the title specified in the article. When configured properly, you can specify the title that goes with the text when you create the article, yet specify the title that goes with the web page when you create the menu item. To set this up in Joomla! 1.5.x, follow these steps. Note for this example I assume that you already have an article set to display the article title (the default setting) and that there is an existing menu item linking to that article: 1. Access the admin system of your site. 2. Click the name of the menu where the menu item you want to change is located. The Menu Item Manager opens. 3. Click on the name of the menu item you want to change. The Menu Item Editing dia- logue opens in your browser. 4. Click on Parameters (System). The Parameters box expands to reveal the options. 5. In the field labeled page title, type whatever you want to appear as the page title for the target of the menu item. 6. Set the value of the parameter named Show Page Title to No. 7. Click the Save icon. The system saves your changes, closes the Menu Item Editing dia- logue, and returns you to the Menu Item Manager. This example results in the title given to the article showing above the text of the article, but the page title given in the menu item will be used for the web page title tag. Note that if you set the menu item parameter named Show Page Title to Yes, then the string you entered in the menu item Page Title parameter would be used as both the web page title tag and as the title above the article text. To extend this technique a bit further, if you need to specify page title tags for pages that are not linked to any menu, you can build a menu whose only purpose is to assist you with the manage- ment of page title tags. To do this, you can create a menu, and then create menu items for each page, specifying in each menu item the page title you desire. The key is to leave the menu module unpublished. If you do not publish the menu module for the menu, then the visitors cannot see the menu or the items it contains, but the page title functionality can still be used to the site administrator to manage the title tag for one or more of the site’s pages. Note The approaches discussed work equally well on menu items that link to components. Chapter 27: Making a Site Search Engine Friendly 727 Tip It is possible to add static text to the existing page title tag, but you have to modify the Joomla! core files to make this happen. Adding static text to the title tag would allow you to specify text that will appear as part of the page title string on all the pages of the site. To make this modification to the system, you must edit the file: libraries/joomla/document/html/renderer/head.php to modify the line of code, that generates the title tag output: $strHtml .= $tab.’<title>’.htmlspecialchars($document->getTitle ()).’</title>’.$lnEnd; Summary This chapter has covered the basics of search engine optimization of your Joomla! web site. You learned the following: l How the enable search engine friendly URLs l How to override the default Joomla! error page template l How to control site and article metadata l How to create effective page titles . friendly URL. The default Joomla! system produces a URL that looks something like this: http://www .joomla1 510 .com/index.php?option=com_content&view=article& id=27:the -joomla- community&catid=30:the-community&Itemid=30 This. the text when you create the article, yet specify the title that goes with the web page when you create the menu item. To set this up in Joomla! 1. 5 .x, follow these steps. Note for this example. this: http://www .joomla1 510 .com/the-community The URL above is a search engine friendly, and human friendly, URL. These two example URLs are real. They actually point to the same page in the Joomla! sample