If this is your first visit, check our documentation. To post, register or login.
Forums / Search Engines / Removing noindex nofollow from category pages with no subcategories or products

Removing noindex nofollow from category pages with no subcategories or products

Started by chrisbucciarelli on 7 Mar 2018, 11:56 PM · Views: 265

Results 1 to 20 of 20
7 Mar 2018, 11:56 PM
#1
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Removing noindex nofollow from category pages with no subcategories or products

Hi, all. I feel I have exhausted the forums for help on this matter to no avail. I have come to realize that categories with no subcategories or products in them generate pages with "noindex, nofollow," which is undesirable. As soon as I add a product to an empty category and view the resulting page, the "noindex, nofollow" is gone. Question is what can I do to NOT have "noindex, nofollow" added to categories that do not contain products. Just because a category does not contain products doesn't necessarily mean I do not want search engines to index them. There is still content on many of the pages I would like Google to index regardless of whether or not products are available within said category. Does this make sense? Is it expected behavior?

I should also mention that I've looked at the code inside all of the files that control whether or not "noindex, nofollow" is added to a page (based on so many previous, helpful posts here) but can't figure out what code I need to affect to have "empty" category pages not have "noindex, nofollow."

Apologies if this concern has been answered already but I feel like I read every single post on this matter today.

Thanks!

8 Mar 2018, 1:20 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Removing noindex nofollow from category pages with no subcategories or products

Haven't gone back to look at 1.5.1; however, more recent versions have a setting:
Configuration Layout Settings Categories - Always Show on Main Page Always Show Categories on Main Page
0= off
1= on
Default category can be set to Top Level or a Specific Top Level ## SHOW_CATEGORIES_ALWAYS 0

That if set to 0 will cause the "issue" described. This is something controlled in: includes/init_includes/init_add_crumbs.php

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Mar 2018, 12:49 PM
#3
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

Hey - thanks for the reply. I did find that setting previously and it was set to '0' so I switched it to '1' yet the behavior still persists. Really at a loss here. Any other ideas?

8 Mar 2018, 1:21 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

The categories/products listing (i.e. the index page) currently contains the following line (zc155f) close to the bottom of the page's header_php.php:

// category is invalid or has no products, so don't index it:
if ($category_depth == 'products' && $listing->RecordCount() == 0) $robotsNoIndex = true;

That's what you're running into. You can change that behavior by creating a file named /includes/modules/pages/index/header_php_allow_index.php, containing:

<?php
// -----
// If categories are always to show, reset the flag!
//
if (SHOW_CATEGORIES_ALWAYS != '0') {
    $robotsNoIndex = false;
}
8 Mar 2018, 1:34 PM
#5
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

Success! You have officially made my day. Thanks so much.

8 Mar 2018, 1:47 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

chrisbucciarelli:

Success! You have officially made my day. Thanks so much.
You're very welcome.

8 Mar 2018, 6:38 PM
#7
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

Unfortunately, I spoke too soon. Because I switched 'Always Show on Main Page' to '1,' my home page now shows all Category links (with corresponding images), as well as Featured Products and Monthly Specials. Obviously, I can make all three boxes disappear by switching 'Always Show on Main Page' back to '0' but that would defeat the purpose. I see options under Admin > Index Listing to disable those boxes on the main page but they are already set to '0' which I assume means do not show. I've also messed with commenting the boxes out of tpl_index_default.php but can't seem to get any results whatsoever. Help?

8 Mar 2018, 6:42 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

Let's step back from the various settings. How about simply describing what you want to have displayed on your main page?

8 Mar 2018, 6:47 PM
#9
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

The main page reading down, should be a header, the main nav, a rotating banner, some copy and then everything in the footer section, but now I'm seeing the three additional boxes mentioned above before the footer.

8 Mar 2018, 7:21 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

What template are you using? Disabling the new/featured/specials blocks via that Index Listing configuration "should" work.

8 Mar 2018, 7:29 PM
#11
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

Genesis. I assumed ownership of this website so don't know too much about what's been installed or modified. But even if those switches should work, why wouldn't I just be unable to comment those boxes out of the template? I figured that would be at least a down and dirty way to not show them for now.

8 Mar 2018, 7:59 PM
#12
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

So, you're editing /includes/templates/genesis/templates/tpl_index_default.php?

8 Mar 2018, 8:02 PM
#13
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

Yes. When none of my changes had any effect, I even renamed that file to see if it would break the home page and it didn't. I'm not even sure that's the correct file at this point. Or maybe some other override is occurring?

8 Mar 2018, 8:07 PM
#14
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

Renaming the file would result in /includes/templates/template_default/templates/tpl_index_default.php being loaded instead.

How about posting the contents of that file (it's pretty small), surrounded by "CODE" tags (the big **# **in the menu-bar when you write your response)?

8 Mar 2018, 8:12 PM
#15
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

<?php
/**
 * Page Template
 *
 * Main index page<br />
 * Displays greetings, welcome text (define-page content), and various centerboxes depending on switch settings in Admin<br />
 * Centerboxes are called as necessary
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_index_default.php 3464 2006-04-19 00:07:26Z ajeh $
 */
?>
<div class="centerColumn" id="indexDefault">
<!--<h1 id="indexDefaultHeading"><?php echo HEADING_TITLE; ?></h1>-->

<?php if (SHOW_CUSTOMER_GREETING == 1) { ?>
<!--<h2 class="greeting"><?php echo zen_customer_greeting(); ?></h2>-->
<?php } ?>

<!-- deprecated - to use uncomment this section
<?php if (TEXT_MAIN) { ?>
<div id="" class="content"><?php echo TEXT_MAIN; ?></div>
<?php } ?>-->

<!-- deprecated - to use uncomment this section
<?php if (TEXT_INFORMATION) { ?>
<div id="" class="content"><?php echo TEXT_INFORMATION; ?></div>
<?php } ?>-->

<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?>
<?php
/**
 * get the Define Main Page Text
 */
?>
<div id="indexDefaultMainContent" class="content"><?php require($define_page); ?></div>
<?php } ?>

<?php
  $show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_MAIN);
  while (!$show_display_category->EOF) {
?>

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_FEATURED_PRODUCTS') { ?>
<?php
/**
 * display the Featured Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_SPECIALS_PRODUCTS') { ?>
<?php
/**
 * display the Special Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_specials_default.php'); ?>
<?php } ?>

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_NEW_PRODUCTS') { ?>
<?php
/**
 * display the New Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?>
<?php } ?>

<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_MAIN_UPCOMING') { ?>
<?php
/**
 * display the Upcoming Products Center Box
 */
?>
<?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS)); ?><?php } ?>

<?php if (true) { ?>
<?php
/**
 * display the Manufacturers Index
 */
?>
<?php } ?>
    
<?php
  $show_display_category->MoveNext();
} // !EOF
?>
<?php 
    if(defined('REVELATION_MANUFACTURERS') && REVELATION_MANUFACTURERS != 'false') {
        require(DIR_WS_MODULES . 'genesis/manufacturers_index.php'); 
    }
?>    
</div>
8 Mar 2018, 8:37 PM
#16
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

Ok - oddly enough, the file I should be editing for whatever reason is tpl_index_categories.php, which I guess is called somehow. Not sure if this is expected but editing this file is allowing me to hide the boxes I mentioned earlier.

8 Mar 2018, 8:46 PM
#17
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

But obviously, editing tpl_index_categories.php, affects the way category pages are shown throughout the site so now the question is how do affect only how it is shown on the home page? Hmm.

8 Mar 2018, 8:58 PM
#18
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

chrisbucciarelli:

But obviously, editing tpl_index_categories.php, affects the way category pages are shown throughout the site so now the question is how do affect only how it is shown on the home page? Hmm.
I believe that that's a side-effect of setting Layout Settings / Categories - Always Show on Main Page to 1. Try changing that back to 0 and changing that additional /includes/modules/pages/index/header_php ... file to read:

<?php
 // ----- 
// Always allow robots to index the categories/products listing. 
// 
$robotsNoIndex = false;
8 Mar 2018, 9:06 PM
#19
chrisbucciarelli avatar

chrisbucciarelli

New Zenner

Join Date:
Mar 2018
Posts:
17
Plugin Contributions:
0

Re: Removing noindex nofollow from category pages with no subcategories or products

And that did it. Thanks again for all the help!

8 Mar 2018, 9:49 PM
#20
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Removing noindex nofollow from category pages with no subcategories or products

Woo-hoo! That's what the forums are for, helping (and learning at the same time).