Page 1 of 2

How to add robots follow header tag?

Posted: Mon Jun 10, 2024 5:15 am
by lecarlb
As the title states, I would like to add a robots header tag that encourages bots to follow and index product and category pages. <meta name="robots" content="index, follow" />

This is for Phoenix version 1.0.8.4

I have implemented the Robots NoIndex header tag module with the desired pages selected.

I've tried copying ht_robot_noindex.php and doing the opposite (removing "no" from noindex) and changing the configuration_group_id from 6 to 25000.

I know the search engines' default action is index and follow, however, I would like to implement this without changing core.

EDIT: I get the following error when trying to install:

Code: Select all

Fatal error: DB: [1305] FUNCTION xxxxxxxxxx_DBZnS4.w does not exist in /usr/local/apache/subdomains/xxxxxxxxx/www.xxxxxxxxx.com/htdocs/includes/system/versioned/1.0.8.1/database_core.php on line 44
Thank you.

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 8:32 am
by burt
Keep it simple..could you just do an `else` in the existing module?

Code: Select all

public function execute() {
  if (!Text::is_empty(MODULE_HEADER_TAGS_ROBOT_NOINDEX_PAGES)) {
    if (in_array(basename(Request::get_page()), page_selection::_get_pages($this->base_constant('PAGES')))) {
      $GLOBALS['Template']->add_block('<meta name="robots" content="noindex,follow" />', $this->group);
    }
    else {
      $GLOBALS['Template']->add_block('<meta name="robots" content="index,follow" />', $this->group);
    }
  }
}
I mildly dislike the idea of two modules doing more or less the same job as it would be too easy to select same page(s) in both modules which would then output;

<meta name="robots" content="noindex,follow" />
<meta name="robots" content="index,follow" />

Which may harm your site SEO. With one module doing the work and a simple if/else switch this becomes an impossibility as the page would show either;
<meta name="robots" content="noindex,follow" />
or;
<meta name="robots" content="index,follow" />
never both.

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 1:53 pm
by lecarlb
@burt

I wasn't excited about a second module either.

That code above didn't work. Here's the piece of code in the file for Phoenix 1.0.8.4:

Code: Select all

    function execute() {
      global $PHP_SELF, $oscTemplate;

      if (tep_not_null(MODULE_HEADER_TAGS_ROBOT_NOINDEX_PAGES)) {
        $pages_array = page_selection::_get_pages(MODULE_HEADER_TAGS_ROBOT_NOINDEX_PAGES);

        if (in_array(basename($PHP_SELF), $pages_array)) {
          $oscTemplate->addBlock('<meta name="robots" content="noindex,follow" />', $this->group);
        }
      }
    }
Thanks

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 3:15 pm
by heatherbell
Change:

Code: Select all

        if (in_array(basename($PHP_SELF), $pages_array)) {
          $oscTemplate->addBlock('<meta name="robots" content="noindex,follow" />', $this->group);
        }
To:

Code: Select all

        if (in_array(basename($PHP_SELF), $pages_array)) {
          $oscTemplate->addBlock('<meta name="robots" content="noindex,follow" />', $this->group);
        }
        else {
          $oscTemplate->addBlock('<meta name="robots" content="index,follow" />', $this->group);
        }

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 4:05 pm
by lecarlb
Thanks @heatherbell, that worked beautifully.

Now I'll keep track in GSC to see what impact, if any, this has on indexing and SEO.

There's mixed feelings online about this. Some say it's useless, some say otherwise.

A lot of the big brands and my competitors, use it.

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 4:19 pm
by lecarlb
This is what it looks like in GSC at time I added robots meta tag

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 4:24 pm
by lecarlb
@burt, @ecartz or anyone the huge number of Excluded by noindex tag is caused by action=notify being appended to the url.

I have the Product Notification PI module installed.

I think there's a way to safely remove that from the url or is it anything to be concerned about?

Thanks

Re: How to add robots follow header tag?

Posted: Mon Jun 10, 2024 10:35 pm
by ecartz
lecarlb wrote: Mon Jun 10, 2024 4:24 pm I think there's a way to safely remove that from the url or is it anything to be concerned about?
That's the product notification sidebox. That should be noindex. You could add nofollow to https://github.com/CE-PhoenixCart/Phoen ... ons.php#L6

Code: Select all

      : '<a class="list-group-item list-group-item-action" href="' . $GLOBALS['Linker']->build()->retain_query_except()->set_parameter('action', 'notify') . '" rel="nofollow"><i class="fas fa-envelope"></i> ' . sprintf(MODULE_BOXES_PRODUCT_NOTIFICATIONS_BOX_NOTIFY, Product::fetch_name($_GET['products_id'])) .'</a>'
Then it won't get to it to noindex it, which might make Google happier.

Re: How to add robots follow header tag?

Posted: Tue Jun 11, 2024 12:07 am
by lecarlb
ecartz wrote: Mon Jun 10, 2024 10:35 pm
lecarlb wrote: Mon Jun 10, 2024 4:24 pm I think there's a way to safely remove that from the url or is it anything to be concerned about?
That's the product notification sidebox. That should be noindex. You could add nofollow to https://github.com/CE-PhoenixCart/Phoen ... ons.php#L6

Code: Select all

      : '<a class="list-group-item list-group-item-action" href="' . $GLOBALS['Linker']->build()->retain_query_except()->set_parameter('action', 'notify') . '" rel="nofollow"><i class="fas fa-envelope"></i> ' . sprintf(MODULE_BOXES_PRODUCT_NOTIFICATIONS_BOX_NOTIFY, Product::fetch_name($_GET['products_id'])) .'</a>'
Then it won't get to it to noindex it, which might make Google happier.
The code for 1.0.8.4 doesn't quite look like that. Here's what I have:

Code: Select all

    echo '<a class="list-group-item list-group-item-action" href="' . tep_href_link($PHP_SELF, tep_get_all_get_params(['action']) . 'action=notify', $request_type) . '"><i class="fas fa-envelope"></i> ' . sprintf(MODULE_BOXES_PRODUCT_NOTIFICATIONS_BOX_NOTIFY, tep_get_products_name($_GET['products_id'])) .'</a>'
In the PI module:

Code: Select all

        $pi_notification_contents .= '<a class="list-group-item list-group-item-action" href="' . tep_href_link('product_info.php', tep_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(PI_NOTIFICATIONS_ADD, $product_info['products_name']) .'</a>
It should be the same fore both, Thanks

Re: How to add robots follow header tag?

Posted: Tue Jun 11, 2024 1:28 am
by ecartz
Replace

Code: Select all

'">
with

Code: Select all

'" rel="nofollow">
in both. Note that this is the same change as before, just with the focus tightened to the part that hasn't changed.