Add Noindex to Specific Pages in Joomla

Keep thank you pages, search results and other thin pages out of Google so your best Joomla pages rank, using one PHP snippet.

Add Noindex to Specific Pages in Joomla
Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Thank you pages, Smart Search results and print views end up in Google's index and compete with the pages you want to rank. Joomla lets you set robots metadata per menu item, but plenty of pages have no menu item, so there's nowhere to set it. You can add noindex to any page with one PHP snippet in Code Snippets, and pick the pages with Conditional Logic.

The PHP snippet code

The snippet adds a robots meta tag to the page's head. Conditional Logic decides which pages it runs on, so you never edit the code to add or remove a page.

use Joomla\CMS\Document\HtmlDocument;
use Joomla\CMS\Factory;

// The value of the robots meta tag.
$robots = 'noindex, follow';

// Do not edit below.

$app = Factory::getApplication();

// Set the tag right before Joomla builds the page's <head>.
$app->registerEvent('onBeforeCompileHead', function () use ($app, $robots)
{
    $document = $app->getDocument();

    if ($document instanceof HtmlDocument)
    {
        $document->setMetaData('robots', $robots);
    }
});

Keep noindex, follow when you want Google to skip the page but still follow its links. Use noindex, nofollow only when you also want those links ignored.

Set up the Conditional Logic before you save. Without it, the snippet runs on every page and tells Google to drop your whole site from its results.

How to add this snippet

  1. Install Code Snippets if it isn't installed already.
  2. Log into your Joomla backend.
  3. Go to Components → Tassos Code Snippets.
  4. Click New.
  5. Enter a title, for example Noindex pages.
  6. Set Code Type to PHP.
  7. Set Insertion Method to Auto-Insert Locations.
  8. Set Location to On Page Load.
  9. Paste the code above into the editor.
  10. Open the Conditional Logic tab:

    • Set Display on to Selected Pages.
    • Click New Condition Set.
    • Click Select Condition and choose Content Article.
    • In Article, pick the articles to hide, for example your thank you page.
  11. Click Save & Close.

Pick pages in the free version

Content Article is a Code Snippets Pro condition. In the free version, choose one of these conditions instead:

  • URL - Query String: enter part of the page's address in URL, like thank-you. Use /component/finder for Smart Search results and tmpl=component for print views. Click + to add more addresses.
  • Menu: tick the menu items to hide. Pages opened from a ticked menu item get noindex too, like the articles of a category blog.

Learn more in Conditional Logic.

Don't also block these pages in robots.txt. If Google can't crawl a page, it never sees the noindex tag, and the address can stay in its index.

Check that it works

  1. Open one of the pages you picked and view the page source.
  2. Look for this line in the <head>:
<meta name="robots" content="noindex, follow">

Pages you didn't pick don't get the tag. To see a page the way Google does, run its address through URL Inspection in Google Search Console. The page drops out of search results after Google crawls it again.

To give every article its own meta description, see Auto-Generate Meta Descriptions from Article Text in Joomla. To learn more about how PHP snippets work, read the PHP snippet docs.

Last updated on Oct 15th 2026 18:10