Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shop Base Appears In Product Sitemap When Page ID is Excluded #7002

Closed
amboutwe opened this issue Apr 17, 2017 · 21 comments · Fixed by #11443
Closed

Shop Base Appears In Product Sitemap When Page ID is Excluded #7002

amboutwe opened this issue Apr 17, 2017 · 21 comments · Fixed by #11443

Comments

@amboutwe
Copy link
Member

What did you expect to happen?

Excluded post/page ID to not show up under any sitemap

What happened instead?

Shop base appears in product sitemap when the page ID is excluded

How can we reproduce this behavior?

  1. Activate Yoast SEO and WooCommerce.
  2. Set shop base under WooCommerce > Settings > Products (tab) > Display (link) > Shop page
  3. Exclude shop base page under SEO > XML Sitemaps > Exclude Posts (tab)
  4. View page sitemap - shop base is excluded. 👍
  5. View product sitemap - shop base appears 👎

Technical info

  • WordPress version: 4.7.3
  • Yoast SEO version: 4.6
  • WooCommerce version: 3.0.3
@amboutwe
Copy link
Member Author

Please inform the customer of conversation # 191015 when this conversation has been closed.

@ethcryptodev
Copy link

Hi there,

Some additional details. This problem also occurs on WooCommerce 2.6.X. I've researched this a lot on the internet and basically in a nutshell Woo always generates the /shop page, even when you clearly specify in Woo that you do NOT want one, or you have one and then delete / clear it. Woo doesn't need the /shop page to operate, but it always seems to make it. Woo refuses to address this issue as they claim it's part of how their plugin works. However, there are thousands of Woo and Yoast users on the internet that want the /shop page GONE from their Yoast product sitemap as it can trigger Duplicate Content penalties from Google SEO, especially if you use other categories or catalogs to display the same products. So, the best fix for this would be if Yoast can do a quick check to see is the WP user has specified a shop page in Woo. If they have not and it's clear or unassigned, then Yoast should auto hide or remove the /shop link from the products sitemap. That way, the issue is solved and everyone is happy and for users that want it, they can have it. Or, there could be a simple option in Yoast or in the Yoast Woo Commerce SEO plugin to choose if you want to hide / remove the /shop link. I have the Yoast Woo SEO plugin as well. Just some thoughts. Please address this when you can.

@stodorovic
Copy link
Contributor

I just saw this. I was trying to fix similar issues and I can explain some details.

Page is listed in page-sitemap because it's page. Any rule which excludes this page will remove it from page-sitemap.

From other side, shop page is archive page for CPT product. Eg. get_post_type_archive_link( 'product' ) will return shop page URL and product-sitemap will show this URL on the begin. (It's archive page and usual rules don't work).

Simple solution is filter:

add_filter( 'wpseo_sitemap_post_type_archive_link', 'my_wpseo_cpt_archive_link', 10, 2);
 
function my_wpseo_cpt_archive_link( $link, $post_type ) {

        // Disable product/post archives in the sitemaps
        if ( $post_type === 'product' )
                return false;

        return $link;
}

This filter removes archive page from the begin of particular sitemap (post, product,...). It's connected on some way with #5450 and #5428. Also, there are many issues related to shop page. (description, title, settings don't work correctly)

@ethcryptodev
Copy link

ethcryptodev commented May 8, 2017

PRAISE CODE JESUS THIS WORKS! Thank you good sir!!!!!!!!!

For anyone that thinks it doesn't, log in to your WP site, change any page or product, save it, then go to Yoast and hit "update" for any setting to refresh it, and then check your Yoast product sitemap again and the dreaded /shop link will be gone!

So happy this is resolved!

@jdevalk
Copy link
Contributor

jdevalk commented Jul 10, 2017

Help me understand: what's "wrong" with that page showing up in the sitemap?

@stodorovic
Copy link
Contributor

Shop page is regular page in Wordpress. So, you can open All Pages and edit it as page. You can also set noindex or title or ... into SEO dashboard bellow WP editor. It removes it from page-sitemap.xml

From other side, woocommerce use this URL (example.com/shop) as product archive page (WP Dashboard -> SEO -> Titles & metas -> Custom Post Type Archives, so it's different location for SEO settings). So, sitemap product-sitemap.xml shows example.com/shop on the top even if page is set to noindex (or excluded from page sitemap).

Examples:

get_post_type_archive_link( 'product' ) returns example.com/shop
get_permalink( wc_get_page_id( 'shop' ) ) returns example.com/shop

Basically, they are different kind of pages (and they use different settings), but it's same URL. There are also some confusion between titles/descriptions/... It's related to #5450 and few similar issues.

@jdevalk I hope that helps for now. I had an idea how it's possible to fix it (I'll try to make PR in next weeks), but for now, I'm using couple filters (see my previous comment) as temporary workaround, I could write more details if you need it.

@ethcryptodev
Copy link

There are many instances where you don't want to use a shop page. Not everyone uses WooCommerce in a standard layout. We use it as a product catalog but we don't do any check out or sales through it. We use different ways that you can browse all our products, so having a forced "/shop" page created redundancies for SEO and potential penalties from Google. We only needed and wanted one way to display all of our products. stodorovic's code correctly removes it from Yoast as there is no other working way to accomplish this for people who do not want or need the /shop page on their sites.

@Pcosta88
Copy link
Contributor

Pcosta88 commented Aug 1, 2017

Please inform the customer of conversation # 211580 when this conversation has been closed.

@Pcosta88
Copy link
Contributor

Pcosta88 commented Aug 7, 2017

Note that this behavior results in the shop page...when it is deleted still appearing on the sitemap
1.Delete shop page

screen shot 2017-07-28 at 3 59 52 pm

2.See that it still appears

screen shot 2017-07-28 at 4 00 16 pm

@Pcosta88
Copy link
Contributor

Pcosta88 commented Aug 7, 2017

USE CASE

From a user:

I do not use the shop feature. I have created pages which link to products and do not see why I should be forced to have this in my sitemap.

@stodorovic
Copy link
Contributor

There is an issue related to post_type archives:

wpseo-pt-archives

Archive page is still included inside sitemaps even meta robots tag is noindex. I'm working on #7668 which will fix it and it's possible workaround for shop page.

@anthiago
Copy link

I solved the issue this way:

Set the "Maximum number of entries per site map" value from 1000 to 1.
Save the changes.
Restore the "Maximum number of entries per site map" to 1000.
Save the changes.

This should delete the shop URL from sitemap.

@jdevalk
Copy link
Contributor

jdevalk commented Jan 20, 2018

@PatrickYoast can you reproduce this?

@PatrickYoast
Copy link

@jdevalk
I was able to reproduce the original behavior @amboutwe described by following the steps she provided. The shop base URL remained in the product-sitemap.xml

xml_sitemap

I was also able to reproduce @Pcosta88 ’s addition where deleting the shop page keeps it in the product-sitemap.xml. Only after refreshing the sitemap (setting the "Maximum number of entries per sitemap" value from 1000 to 1) the sitemap showed as test-shop-page__trashed.

35433348-6b1df9fe-0283-11e8-8f0a-b54e5c1d8b23

@PatrickYoast PatrickYoast removed their assignment Jan 26, 2018
@galbaras
Copy link

galbaras commented Mar 5, 2018

I can see archive pages for other custom post types (WooThemes testimonials, in one case) being shown at the top of the post type sitemap. Could this be related to how the type or taxonomy are registered?

There's been no update since this issue was marked as a bug on 27 January. Is a fix coming?

@strarsis
Copy link

strarsis commented Sep 7, 2018

Related?: woocommerce/woocommerce#21297

@Pcosta88
Copy link
Contributor

Pcosta88 commented Oct 3, 2018

Please inform the customer of conversation # 431001 when this conversation has been closed.

@stodorovic
Copy link
Contributor

@strarsis The issue which you've been meaning isn't similar as this issue. Possible fixes for woocommerce/woocommerce#21297 are:

  • Install Yoast WooCommerce SEO plugin
  • Set Allow search engines to show this Page in search results? to "No" for these pages (Yoast SEO metabox).
  • Use the filter wpseo_exclude_from_sitemap_by_post_ids.

@stodorovic
Copy link
Contributor

I've created #11443 which fixes this issue. Regarding that 'SEO > XML Sitemaps > Exclude Posts' doesn't exist as option (WP Dashboard) in the latest version, this PR checks only "noindex" field for shop page if product sitemap is requested.

@strayangelfilms @Pcosta88 It would be great if you could test #11443 as it needs to solve this issue.

@Pcosta88 I don't think that's useful to check status of shop page, but I could add additional code into method get_post_type_archive_link. It's a very rare case (deleted shop page or posts page into settings). What you think?

@karimaziz
Copy link

@Pcosta88 any news on this?

@juanisidoro
Copy link

juanisidoro commented Oct 13, 2021

@stodorovic Thanks!!
this hook helped me a lot.
Thank you!!!

Delete URL /shop in the sitemap: /product-sitemap.xml with Yoast SEO

add_filter( 'wpseo_sitemap_post_type_archive_link', 'my_wpseo_cpt_archive_link', 10, 2);
function my_wpseo_cpt_archive_link( $link, $post_type ) {
        // Disable product/post archives in the sitemaps
        if ( $post_type === 'product' )
                return false;
        return $link;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.