Question on the code that allows only the first page of category pages to be indexed

googlealchemist

Google Alchemist
Joined
Mar 17, 2023
Messages
54
Likes
30
Degree
0
I'm truly not trying to be lazy here but my brain is short circuiting on this.

But if I add the code thats been mentioned in various posts here, that only allows the first page, which I can flesh out so its not thin, of my category pages to be indexed...

Is that going to be a conflict with the yoast settings where i set the categories to noindex?

Or how do i reconcile this?
 
You would choose to not use that setting in Yoast. Then the code would say, in human talk, “only set the first paged page to be indexed, and set the rest to noindex”.

For those in need of the functions.php snippet:

<?php if ( is_paged() ) { echo '<meta name="robots" content="noindex,follow" />'; } ?>

“Paged” means anything past page 1. If you leave the Yoast function on, it’ll add that to page 1 as well, which you don’t want.
 
You would choose to not use that setting in Yoast. Then the code would say, in human talk, “only set the first paged page to be indexed, and set the rest to noindex”.

For those in need of the functions.php snippet:

<?php if ( is_paged() ) { echo '<meta name="robots" content="noindex,follow" />'; } ?>

“Paged” means anything past page 1. If you leave the Yoast function on, it’ll add that to page 1 as well, which you don’t want.

Thank you!

By 'not using that setting' does that mean leaving the "Show categories in search results" set as enabled in yoast, and therefore letting the functions snippet do the noindexing instead?

Same for the author archives?

But if I don't use tags at all, I would just leave that to disabled for those in yoast?

Same for date and format archives?
 
If you allow Yoast to say "show categories in search results" then that's the default behavior anyways. Categories (page 1 and page 2 ... page 999) will be indexable.

If you tell Yoast NOT to "show categories in search results" then it'll add <meta name="robots" content="noindex,follow" /> to all of the category pages.

The code snipped shared above only adds <meta name="robots" content="noindex,follow" /> to pages 2 and beyond, making them noindex, while allowing page 1 to continue to be indexed.

If you tell Yoast NOT to "show categories in search results" while also using this code snippet, then not a single category page will be indexable, because the snippet will be saying "don't index page 2 and beyond" while Yoast will be saying "don't index the 1st page or any others". So when they add together, nothing gets indexed.

Same for the author, date, and format archives. You can disable entire sets of these (which will make it so you don't even have the choice to set those sets to be noindexed since the pages won't be generated).

Yes, if you don't want to use tags, just keep tags disabled altogether.

Let's say there's a scenario where you use categories, tags, date archives, author archives, and format archives. That code snippet will work for all of them, because all of their "page 2 and beyond" pages will be considered "paged", which is what the code snippet targets with the function is_paged().
 
Back