Joomla Tips: How to assign body IDs to each page

Here is the code I use to add an individual ID to each page in a Joomla website. In index.php of your site’s template folder, add this code in place of the < body> tag:

<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
?>
<body id="<?php print $active->alias; ?>">

Now, each page will have it’s own ID. For example, www.yourwebsite.com/about-us will have the ID “about-us.”