• Resolved cncup

    (@cncup)


    I have a page (ie. not post) built dynamically. It may or may not have URL parameters (‘query string’).

    Consider the following 5 URLs:

    mysite.com/mypage
    mysite.com/mypage?paramA=1
    mysite.com/mypage?paramA=2
    mysite.com/mypage?paramB=1
    mysite.com/mypage?paramB=2

    Each of these 5 is its own canonical and has its own meta description and title, achieved with the filters wpseo_canonical, wpseo_metadesc and wpseo_title, respectively.

    So far so good.

    Now I want each of the 5 to be a separate entry in the sitemap (under page-sitemap.xml). How to do that?

    Thanks.

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

    (@maybellyne)

    Hello @cncup

    Thanks for reaching out regarding your sitemap. URLs with parameters won’t be included in the sitemap because the canonical URL defaults to the original URL. The canonical URL will be in the sitemap, not the one with parameters.

    For instance, mysite.com/mypage will be included in the sitemap because it’s also the canonical URL of the page, while the parameterised URL (mysite.com/mypage?paramA=1) won’t be included.

    Thread Starter cncup

    (@cncup)

    Hi @maybellyne.

    Thank you for your reply.

    Yes, this is why I mentioned the wpseo_canonical filter. I’m changing the canonical, so the canonical for a parameterized URL is itself.
    (removing ‘garbage’ params to avoid duplicates)

    I came across the wpseo_sitemap_index filter. The implementation is a bit involved if I want the sitemap-addition to be all the way dynamic. There is this code on github that I will try to modify to my needs. But that would be the way to go, right?

    Or is there a simpler way?

    Plugin Support Maybellyne

    (@maybellyne)

    Yes, you can use the wpseo_canonical?filter to change the canonical URL that Yoast SEO generates for a URL programmatically. Please check out our developer portal

    Thread Starter cncup

    (@cncup)

    It seems I’m not getting through for the second time. The question is NOT about canonical.

    It’s about adding custom sitemap, dynamically.

    For future reference, what I tried with the link I provided earlier worked. Credit and thanks to leepowers on GitHub.

    Still would be nice to know if there is a simpler way to do it.

    Third time’s the charm?

    Plugin Support Maybellyne

    (@maybellyne)

    There’s no feature to add a custom sitemap, dynamically unless you are referring to an external sitemap.

    Thread Starter cncup

    (@cncup)

    Custom, external, same thing. The doc you linked says in the comment above the code “Writes additional/custom XML sitemap”.

    And I’m ahead of this example, it uses hard coded values. The link I provided shows a way to get the values dynamically, and the question was about that.

    So I infer from the A being two steps behind the Q and the ongoing lack of a direct reply that there is no simpler way.

    The issue can be closed.

    All the best

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to include URLs with parameters in the sitemap?’ is closed to new replies.