Manually Remove Specific URL from Sitemap

#79370
  • Resolved Zsolt Siklodi
    Rank Math pro

    Hi team. Thank you for the great plugin #kudos. Could not find a way nor find a topic on this forum about how I can exclude a specific page from the sitemap. Of course, there is the usual way of ‘noindex’. However, my set-up is slightly weird:

    https://www.adventurequest.ae/portfolio-sitemap.xml

    Here we have the following url https://www.adventurequest.ae/activities/ which I would like to remove as it is a 301 redirect. Why? Because the ‘activities’ page is a portfolio item for all the activities and we aren’t using this page and is automatically generated (ARCHIVES: PORTFOLIO) – hence no page for the ‘noindex’. So far it is redirecting to /our-offering/ which is fine.

    Any idea how to remove it from the sitemap please? 🙂

    Thanks,
    Z

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can use the option in Rank math to exclude posts/pages with their ID in Rank math > Sitemap Settings
    img

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hi Michael,

    Thank you for your reply. Sadly this isn’t a page like ‘posts’,’pages’ or ‘tag’ which have an ID. This is automatically generated ‘archive’ page which I am not sure what is the best way to exclude.

    Thanks,
    Z

    Hello,

    Assuming the page you want to exclude is the only one with the /activities/ slug. You can add a noindex tag to your page with the following filter:

    
    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
         global $post;
         $page = get_posts( array( 'name' => 'activities' ) );
         if($page){
            $robots['index'] = "noindex";
            $robots['follow'] = "follow";
            return $robots;
         }
    	return $robots;
    });
    

    If you don’t wish to index the URLs you can just disallow the URL slug with the robots.txt:

    
    Disallow: /activities/
    

    Hope that helps you. Thank you.

    ​​​​​​

    Hi Michael,
    Thank you for the detailed reply. As this page doesn’t exist, I am not quite sure on how to add the above or does it need to be added somewhere specific within the plugin section.

    Regarding updating the robots.txt file would not actually solve the issue of removing the incorrect URL from the sitemap 🙂

    Kind regards,
    Zsolt

    Hello,

    If the page doesn’t exist, it should not be included in the sitemap. Have you tried clearing the cache?

    Else, please share the URL that doesn’t exist but appears in your sitemap anyway.

    We look forward to hearing back from you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hi Uzair,

    Thank you for your help on this. Indeed, the ‘page’ is automatically being generated which makes it quite tricky to exclude from the sitemap. Maybe, there is a trick that I am missing.

    This is the URL: https://www.adventurequest.ae/activities/

    As per previous explanation, this is an ‘archive’ page for the portfolio pages.

    Would be nice to have an option where you can just specify the slug to be excluded from the sitemap – but not sure technically if that is achievable.

    Thank you for looking into my request.

    Kind regards,
    Zsolt

    Hello,

    We are sorry but that is not possible since the page technically doesn’t exist in the backend so there is no way to grab its ID or make it noindex.

    ‘You can add a noindex tag to your page with the following filter:’
    Where would you paste that noindex tag in wordpress?

    Thanks

    Alberto
    Rank Math business

    Hello,

    You should paste that code in the functions.php file in your active theme, but keep in mind you would need to configure it to fit your needs.

    Looking forward to help you.

    Thank you for the replies.
    @zaphire: already tried, but this ‘page’ does not exist (sadly), would be an easy fix


    @alberto
    : what should I be pasting in the functions.php? Happy to try any option.

    Thanks,
    Z

    Hello,

    The code can be added at the end of the active theme functions.php file.

    You can also get in touch with the portfolio plugin developer and ask them how you can edit the page that way you can find a way to add the noindex tag and easily exclude it from sitemap.

    If you have any further question(s), please let us know. Thank you.

    Hi Michael,

    Tried adding the above code in the the functions.php (child and master), but the link still showed up in the sitemap.xml.

    Thanks,
    Z

    Hello,

    Did you get in touch with the portfolio plugin team.?

    There’s nothing we can do from our end if the page doesn’t exist on your site in actual sense. Only the plugin developer can guide how they are generating the URL to be able to remove it from sitemap.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 14 replies - 1 through 14 (of 14 total)

The ticket ‘Manually Remove Specific URL from Sitemap’ is closed to new replies.