News:

Support the VirtueMart project and become a member

Main Menu

How to Block Google from Indexing Print Page...

Started by hotrod, December 09, 2023, 04:45:27 AM

Previous topic - Next topic

hotrod

I'm not showing the print icon and have that turned off.. But I'm seeing some of my products are indexed by the print page..
/shop-now/compressor-abpn83304783-detail?tmpl=component&print=1

What would be the line I put into the robot.text...
Bronze Member
VirtueMart 4.2.4 10922
Joomla!  ‎4.3.4
PHP 8.0

Jumbo!

It can not done using robots.txt

You can ask the robots not to index these pages by adding the following codes to your template's component.php file. i.e., templates/YOUR-TEMPLATE-FOLDER/component.php

<?php
JFactory
::getDocument()->setMetaData('robots''NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
?>


OR

<?php
if (JFactory::getApplication()->input->getInt('print'0)) {
    
JFactory::getDocument()->setMetaData('robots''NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
}
?>

hotrod

Bronze Member
VirtueMart 4.2.4 10922
Joomla!  ‎4.3.4
PHP 8.0

sirius

mmmm

Disallow: /*&print=1

works ok in robots.txt
but agree that it just block the access, and google need to access to know IF it must index it or not.
J3.10.12 | PHP 7.4.33 + APC + Opcode
VM Prod : 3.8.6 | VM Test : 4.4.0.11095