Skip to content

Clarify side effects of not setting site_url #1783

Open

Description

Sitemap generated with empty loc tags, i.e.

    <url>
     <loc></loc>
     
     <changefreq>daily</changefreq>
    </url>

Example attached.
sitemap.xml.gz

Effect

Causes Google Search to report errors, request correction and resubmission.

Version

☕ sjt@max:~/kx/code/v2$ mkdocs --version
mkdocs, version 1.0.4 from /usr/local/lib/python3.7/site-packages/mkdocs (Python 3.7)

Configuration

mkdocs.yml.txt

Activity

  1. waylan commented on Apr 19, 2019

    @waylan
    Contributor

    Do you have external links in your nav config? If so, then this is a duplicate of #1742, which was fixed in #1748 and will be available in the next release.

    Sorry, but I'm not downloading random files from bug reports. You can include the relevant section of the config in a comment if you want to share it.

  2. trel commented on Apr 19, 2019

    @trel
    Contributor

    I saw a couple smart quotes in the nav listing - not sure if that could be relevant/responsible.

  3. brandongc commented on Apr 25, 2019

    @brandongc
    Contributor

    I found that if I do not have site_url defined in my yaml file then all of the <loc> tags are None. Do you have that set?

  4. aeromusek commented on May 30, 2019

    @aeromusek

    @brandongc lifesaver — we had this issue too and I never got around to debugging it. A bit harder to track down, cause it works fine with mkdocs serve (I bet there's an undocumented default value being injected)

  5. waylan commented on May 30, 2019

    @waylan
    Contributor

    @aeromusek you are correct. When using serve, the site_url setting is set to the value of dev_addr. This is necessary to avoid things breaking on the local server.

    This seems to trip people up more than I expected. Perhaps we should make it a "required" setting as a number of things break without site_url defined. The problem with that is that requires a URL be defined immediately when a new project is just getting started. Sometimes its nice to play with things for a while before reaching the point where we think about the domain.

    Either way, we probably should document this. And at the least do a better job of calling out the site_url setting as many new users are missing that this setting exists, let alone setting it.

  6. brandongc commented on May 31, 2019

    @brandongc
    Contributor

    Perhaps issuing a WARN or INFO on mkdocs build when site_url is not defined?

  7. aeromusek commented on May 31, 2019

    @aeromusek

    The behavior makes total sense and is quite elegant, once it's clear how things are working. Jekyll actually does exactly the same thing.

    The confusing part for me was having (seemingly random) things like the sitemap break without any clear reason. At the least, I think it would be helpful to add some additional details here, including that this value is used for more than just the canonical metatag, and that it's really not optional for a production environment.

    A WARN or INFO also would be helpful.

  8. changed the title [-]Sitemap generated with empty url/loc tags[/-] [+]Clarify side effects of not setting `site_url`[/+] on Apr 17, 2024
  9. pawamoy commented on Apr 17, 2024

    @pawamoy
    Contributor

    I've edited the title to keep this issue as open as a documentation issue: not setting site_url can have some side-effects as the one described here (empty sitemap when building but not when serving).

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions