image

TYPO3 How to tell Google not to index the page in search results using meta tag

Here I am extending the table pages to have the checkbox "No index" on every page.

On ext_tables.sql of custom extension,

CREATE TABLE pages (

   no_index tinyint(4) DEFAULT '0' NOT NULL

);

 

In ext_tables.php

$tempColumns = array(

  'no_index' => array(

    'exclude' => 1,

    'label' => 'No index',

    'config' => array (

      'type' => 'check',

      'default' => '0'

    )

   ),

);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(

   'pages',

   $tempColumns,

  1

);

 

#add field in specific place

$myPallet = '--div--,no_index';

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(

   'pages',

   $myPallet

);

In TS template

page = PAGE

page.meta{

   robots = INDEX, FOLLOW

   robots.override = NOINDEX, FOLLOW

   robots.override.if.isTrue.field = no_index

}

The above typoscript adds the meta tag

<meta name="robots" content="NOINDEX, FOLLOW">  if the "No index" check box is checked. This meta tag tells the google that, not to index this page.

That's it.