Exclude pages from site map.xml

Solved
phil_CM
Excursionist
72 1 1

Is it possible to exclude pages from the site map? (Without using an App)

I don’t mean how to stop them being indexed as I have already implemented this but obviously now Google webmasters sees these pages as an issue as they are included in the site map. 

many thanks in advance 

0 Likes
g33kgirl
Shopify Partner
211 52 65

@phil_CM, this should help: https://shopify.dev/tutorials/manage-seo-data-with-admin-api#hide-a-resource-from-search-engines-and...

If you found my answer helpful, please LIKE and ACCEPT.
buymeacoffee.com/g33kgirl ☕
If you're not comfortable with code, please modify code files at your own risk.
Do NOT give out your passwords unless absolutely necessary.
0 Likes
phil_CM
Excursionist
72 1 1
Click to expand...
 

I’m not sure how to implement admin API. It is specific products I want to exclude from the site map links 

0 Likes
KieranR
Shopify Partner
218 20 56

This is an accepted solution.

Answer from @g33kgirl is correct but doing so via the Admin API can be technically challenging.

There are two easier ways to manage this other than directly interfacing with the API. 

  1. Use a metafields app. I know off the top of my head that Accentuate Custom Fields has a built in setting to control the seo/hidden interger flag from a control panel
  2. Use the Shopify bulk editor with a metafield URL string like: https://your-store.myshopify.com/admin/bulk?resource_name=Product&edit=metafields.seo.hidden
    • or select your Products, then fire up bulk editor, then add the bolded bit to the bulk edit URL
    • you'll need to set the value 1 for any products you want hidden

This field will do the following: 

  • remove the product URLs from the sitemap.xml structure
  • hide the products from internal site search
  • add NOINDEX,NOFOLLOW tags to the pages
  • leave the pages live

Can I ask why you're trying to do this? Might be a different/better approach to the same end goal.

 

Full time Shopify SEO guy, based in NZ. Sometimes freelance outside the 9-5.
0 Likes
phil_CM
Excursionist
72 1 1

I have products I have added noindex to. The reason for this is that they are “dummy products”. They are products of variants of the same product and simply redirect to a main product with that variant selected. So I added noindex to these as otherwise it would appear that I was trying to do something dodgy with the pages other than their real purpose which is to improve user experience.

now that I have these pages set with noindex, they currently still exist in the sitemap so Google sees them as being set to noindex as an error. It’s no great big deal but I would like to wrap up the logic by having them removed from the sitemap.

as I set the noindex using a tag on the product, can I run the admin api on the product template code based on this tag in the same way and auto set the product of accordingly? Is this how you run the admin api as a script in the store code?

0 Likes
KieranR
Shopify Partner
218 20 56

The Admin API can be accessed programmatically via REST/GraphQL requests. It's not too hard to do if you already know what that means.

The suggestion is to set a flag metafields.seo.hidden integer on a product (can't set it per product variant, has to be at the product level). You can do this by API or you can do it by the options (1/2) I gave which IMO are a bit simpler to do.

If Shopify sees metafields.seo.hidden == 1 on a product/collection/blog/blog-article resource then it will inject a NOINDEX,NOFOLLOW meta tag inside the {{ content_for_header }} include in the HTML of that page.

If you also have a custom noindex tag defined within the <head> tags then you'll end up with duplicate noindex tags. You can't access the Admin api via liquid templating alone, there is no way to do HTTPs requests (or any 'proper' server-side logic) within liquid templating.

An alternative approach here would be using custom canonicals, but need more context to know if that would make sense.

 

 

Full time Shopify SEO guy, based in NZ. Sometimes freelance outside the 9-5.
0 Likes
phil_CM
Excursionist
72 1 1

I’ll give this method a go 

  1. Use the Shopify bulk editor with a metafield URL string like: https://your-store.myshopify.com/admin/bulk?resource_name=Product&edit=metafields.seo.hidden
    • or select your Products, then fire up bulk editor, then add the bolded bit to the bulk edit URL
    • you'll need to set the value 1 for any products you want hidden

I assume I don’t need the App to do this and can be done using the admin as it is?

0 Likes
phil_CM
Excursionist
72 1 1

The only thing with doing this is that I currently set noindex, follow rather than no index no follow.

 

0 Likes
phil_CM
Excursionist
72 1 1

Thinking about it I probably don’t want the products removed from the internal site search though. So I may have to give in a leave it where I have it.

 

thanks all for your advice

0 Likes