• Resolved stefk

    (@stefk)


    Is there a way to redo this function to exclude a URL from the sitemap?

    add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
      return array( 311, 322 );
    } );

    Or is it better to do this in the robots.txt?

    The issue is that the URL is non-existant, and has a % in the slug, so a redirect won’t work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @stefk

    Could you please clarify further the non-existent URLs you want to exclude from the sitemap? In addition, could you please show us some example URLs where the issue occurs so that we can take a look at them?

    Thread Starter stefk

    (@stefk)

    A URL popped up on google webmaster tools, which is flagged with a crawl issue.

    The example below:
    domainname.com/products/%products_categories%/tablet-pc

    So initially I tried to do a redirect of that URL to another page, but redirect won’t work on it, I’m guessing because of the % in the slug.

    So my thinking is that I need to exclude this URL, even though it does not exist from being crawled.

    Hi @stefk

    If the URL(s) doesn’t exist on its own and is being flagged as a crawl issue (say 404) in your Google Search Console it is less likely that Google will continue recrawling them.

    Having said that, even if you don’t create a redirect for that 404 URL, Google will eventually find out that the URL isn’t available on your website and will stop showing a 404 error for it. If you want to learn more about 404 errors, please refer to this post: https://yoast.com/404-error-pages-checking/

    Sa?a

    (@stodorovic)

    Character % in URL should be encoded as %25. Anyway, it seems as broken permalink structure in WooCommerce. It uses the placeholder %product_cat% (not %products_categories%) which should be replaced with product category slug. Maybe it’s added by 3rd plugin.

    The filter wpseo_exclude_from_sitemap_by_post_ids works only for real products from the database (not for archive pages or “virtual” pages). If you set product/page/post to noindex then it’s automatically removed from the sitemap.

    Thread Starter stefk

    (@stefk)

    @stodorovic @suascat_wp Thank you for your inputs, both valid suggestions, and comments.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude Sitemap Indexing for Non Existant URL’ is closed to new replies.