Skip to content

Remove alternate tag if the href is undefined #44

Description

@bherrero

Hi!! I've got multiple languages on my site and most of them would have their equivalent URL for the corresponding language. However, in some cases, the URL is only available in one or two languages.

Example:

<url>

        <loc>https://mydomain.com/legal/cookies-policy/</loc>


        <lastmod>2023-02-27T06:46:41.122Z</lastmod>
    
        <xhtml:link rel="alternate" hreflang="es" href="undefined" />
        <xhtml:link rel="alternate" hreflang="pt" href="undefined" />
        <xhtml:link rel="alternate" hreflang="fr" href="undefined" />
        <xhtml:link rel="alternate" hreflang="de" href="undefined" />
        <xhtml:link rel="alternate" hreflang="ru" href="undefined" />
    </url>

Is there any way of avoiding that?
Seeing the code, only pushing the tag if href is defined seems like a quick fix. I could submit a PR if needed.
Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions