Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure site_url ends with a slash #2360

Merged
merged 1 commit into from
Apr 10, 2021
Merged

Ensure site_url ends with a slash #2360

merged 1 commit into from
Apr 10, 2021

Conversation

waylan
Copy link
Member

@waylan waylan commented Apr 10, 2021

urlparse(config['site_url']).path can be empty if site_url does not end
in a slash. This ensures at least a slash is returned. Config validation
will add the slash if it is missing. Fixes #1785.

`urlparse(config['site_url']).path` can be empty if `site_url` does not end
in a slash. This ensures at least a slash is returned. Config validation
will add the slash if it is missing. Fixes mkdocs#1785.
@waylan waylan merged commit d99419a into mkdocs:master Apr 10, 2021
@waylan waylan deleted the 1785 branch April 10, 2021 22:43
br3ndonland added a commit to br3ndonland/inboard that referenced this pull request Jul 7, 2021
#34
36eca9d
a877045

https://www.mkdocs.org/user-guide/configuration/#site_url
https://www.mkdocs.org/user-guide/configuration/#use_directory_urls
mkdocs/mkdocs#2189
mkdocs/mkdocs#2360

https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/
squidfunk/mkdocs-material#2520

MkDocs recently made the `site_url` setting required. A warning is now
seen when `site_url` is not included in mkdocs.yml:

```text
WARNING  -  Config value: 'site_url'.
            Warning: This option is now required. Set to a valid URL
            or an empty string to avoid an error in a future release.
```

The docs describe the `site_url` setting as follows:

> Set the canonical URL of the site. This is a required setting. If the
> 'root' of the MkDocs site will be within a subdirectory of a domain,
> be sure to include that subdirectory in the setting
> (https://example.com/foo/). If the domain is yet to be determined, you
> may use a placeholder domain, which will need to be updated prior to
> deployment.
>
> If the built site will not be behind a server, then you may set the
> value to an empty string (''). When set to an empty string, some
> features of MkDocs may act differently. For example, the
> `use_directory_urls` setting must be set to false.

If the docs are "behind a server," they often have more than one URL.
Which should be set as the `site_url`? Furthermore, if the related
`use_directory_urls` is set to `true`, it appends a trailing slash to
the URLs generated for the ToC (Table of Contents).

This commit will set `site_url: ""` and `use_directory_urls: false`.
In combination with the `{"cleanUrls": true, "trailingSlash": false}`
settings in vercel.json, the previous behavior of URLs and navigation
will be restored.
br3ndonland added a commit to br3ndonland/fastenv that referenced this pull request Jul 7, 2021
#1
br3ndonland/inboard#34
br3ndonland/inboard@9943112

https://www.mkdocs.org/user-guide/configuration/#site_url
https://www.mkdocs.org/user-guide/configuration/#use_directory_urls
mkdocs/mkdocs#2189
mkdocs/mkdocs#2360

https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/
squidfunk/mkdocs-material#2520

MkDocs recently made the `site_url` setting required. A warning is now
seen when `site_url` is not included in mkdocs.yml:

```text
WARNING  -  Config value: 'site_url'.
            Warning: This option is now required. Set to a valid URL
            or an empty string to avoid an error in a future release.
```

The docs describe the `site_url` setting as follows:

> Set the canonical URL of the site. This is a required setting. If the
> 'root' of the MkDocs site will be within a subdirectory of a domain,
> be sure to include that subdirectory in the setting
> (https://example.com/foo/). If the domain is yet to be determined, you
> may use a placeholder domain, which will need to be updated prior to
> deployment.
>
> If the built site will not be behind a server, then you may set the
> value to an empty string (''). When set to an empty string, some
> features of MkDocs may act differently. For example, the
> `use_directory_urls` setting must be set to false.

If the docs are "behind a server," they often have more than one URL.
Which should be set as the `site_url`? Furthermore, if the related
`use_directory_urls` is set to `true`, it appends a trailing slash to
the URLs generated for the ToC (Table of Contents).

This commit will set `site_url: ""` and `use_directory_urls: false`.
In combination with the `{"cleanUrls": true, "trailingSlash": false}`
settings in vercel.json, the previous behavior of URLs and navigation
will be restored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong paths in 404 page on mkdocs.org
1 participant