• Resolved George

    (@giorgos93)


    Hi! I use YoastSEO XML sitemap on my website, and I have always wondered: why the main page link is shown in both page-sitemap.xml and post-sitemap.xml? Is it necessary to have it in both sitemaps?

    Thanks in advance for an answer!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello George,

    Thanks for reaching out.

    This behavior is caused due to how WordPress sets the ‘Posts page’. When you set ‘Posts page’ in WordPress under Settings > Reading, then WordPress uses the same URL for two different page types. You can read more information about this here: https://github.com/Yoast/wordpress-seo/issues/10994#issuecomment-436201395

    As for how to resolve it, we’d recommend manually removing one instance of the URL from the page-sitemap.xml using a developer filter such as in the following code example:

    add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', 'my_sitemap_excludes' );
    
    function my_sitemap_excludes( $pages ) {
    	$pages[] = get_option( 'page_for_posts' );
    	return $pages;
    }
    Thread Starter George

    (@giorgos93)

    Thanks for quick answer!

    I’ve just added this code at the end of my theme’s functions.php file (right before ‘?>’), but for some reason it didn’t change anything.

    Do I have to wait for it to work? Or I put this code in a wrong file / wrong place of file?

    Thanks in advance for an answer!

    Plugin Support devnihil

    (@devnihil)

    @giorgos93 Thanks for your reply.

    Unfortunately we can’t offer support on custom code (needed to change (core) features of our plugin). Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes.

    If the code example isn’t working as expected in your theme, we recommend reaching out to your theme’s developer for advice on where in it’s functions.php to best implement the code.

    Thread Starter George

    (@giorgos93)

    Thanks for the answer, but I am experienced user, and 99% sure, that this code was put in a right place. I’ve already modified functions.php file several times before.

    The problem is in this code, I think. Because someone already wrote in other topic, that this code doesn’t work: https://wordpress.org/support/topic/homepage-shows-up-in-post-and-page-sitemap/ . Also, other user mentioned there, that a filter ‘wpseo_sitemap_post_type_archive_link’ has to be used, to do that. Any thoughts on that?

    Plugin Support Suwash

    (@suascat_wp)

    @giorgos93

    We’ve confirmed the appearance of homepage URL on both post and page sitemap when same page is set as static page and post page. This is expected behavior. The way WordPress works results in this behavior. It is not expected to affect the SEO of your site. Additionally, this issue has also been discussed earlier with our developers. They concluded it is not a real concern with the sitemap. You can also refer to the GitHub discussion here: https://github.com/Yoast/wordpress-seo/issues/5428.

    As much as we hate to say it, your question goes beyond the technical expertise of me and my colleagues on the Yoast support team. This means we can’t give you a solid answer to your question.

    But we don’t want to leave you empty-handed either, that’s why we’ve created our developer portal at developer.yoast.com. This has proven to be useful to many developers in the past, and hopefully will serve you well too.

    Sorry we can’t be of more help here.

    Plugin Support devnihil

    (@devnihil)

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Question about YoastSEO sitemap’ is closed to new replies.