How to add robots follow header tag?

Open to all! Ask other shopowners for help.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

How to add robots follow header tag?

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: How to add robots follow header tag?

Post 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.
I am not here to build for you.
I am here to build with you. Let's help each other.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to add robots follow header tag?

Post 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
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: How to add robots follow header tag?

Post 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);
        }
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to add robots follow header tag?

Post 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.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to add robots follow header tag?

Post by lecarlb »

This is what it looks like in GSC at time I added robots meta tag
You do not have the required permissions to view the files attached to this post.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to add robots follow header tag?

Post 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
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: How to add robots follow header tag?

Post 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.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: How to add robots follow header tag?

Post 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
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: How to add robots follow header tag?

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply