Add page name / suffix to website title

If you want search engine results to show your page titles like this:
Your article title which is usually longer | Your Page

The page title appears in browser title bars and search engines. There are extensions available for managing page title suffixes/prefixes and adding your desired content before or after your page titles. But, there is a really simple way of adding your page name to page titles:

  1. Log in to your sites administration panel.
  2. Go to Site -> Global Configuration
  3. On the right locate SEO Settings
  4. Change the value of Include Page Name in Page Titles to Before or After, which you prefer.
  5. Save and refresh your website view

 

The same thing can be achieved using a few lines of code in your template index.php file, shis is useful when you'd like to have your own separator to the titles. Here's how:

  1. Open index.php from your template folder for editing. You can do it even from the Joomla! administrator panel going through Extensions -> Templates -> Templates and selecting your template (be sure to set the file writable on your server, else you'll not be able to edit it).
  2. Add the following lines of code to right before the head closing tag </head>

    /* start code */

     <?php // let's change the page title to TITLE | SITENAME
    $document =& JFactory::getDocument();
    $document->setTitle($document->title . " | Your Desired Page Title Here ");
    ?>

    /* end code*/

    * note that in this example | is used as a separator. You can use whatever you like instead of it. 

  3. Save and refresh your page.

ADs top-right (2)

About me

Iinstructor of robotics (LEGO Mindstorms), computer teacher, IT support, web dev, currently studying cyber-physical systems engineering.

If you found a solution here, would you consider donating $25,000 for my next project?

Just kidding, 1$ would do fine.

Hope you found what you needed. Thanks for stepping by.