Skip to content

Use absolute URLs in nav & media links from error templates. - #1039

Merged
waylan merged 1 commit into
mkdocs:masterfrom
waylan:nav
Aug 29, 2016
Merged

waylan merged 1 commit into
mkdocs:masterfrom
waylan:nav

Conversation

@waylan

@waylan waylan commented Aug 28, 2016 •

Copy link
Copy Markdown
Contributor

An error page can be served from any location and therefore it is
impossable to pre-build an error page with correct relative URLs.
With absolute URLs, the error pages will properly link to other
pages in the nav as well as media files (css, js, images, etc) from
the template regardless of the actual URL the file is served from.

However, to continue to support environments where the docs root is a subdir
of the server root, all other pages must continue to use relative URLs.
The site_url is used to determine the server root when building
absolute URLs for the error page to ensure those URLs continue to work
in that type of environment.

Relative URLs are also nessecary for those who browse the site on the
local file system (via file://). In that case, the error page will be
broken. However, as error pages are not served by a local file system,
this is no more than a minor inconvience. Error pages should always be
tested from a server environment.

Fixes #77.

@waylan

waylan commented Aug 28, 2016

Copy link
Copy Markdown
Contributor Author

I haven't added any tests for this. Not sure what to include there. However, everything seems to work in manual testing.

Also missing a comment in the release notes. I don't think we need anything else added to the documentation. The site_url config setting's docs are already clear that it should include the entire URL to the docs root, and that's really the only user facing piece of this. To the end user (and theme devs), it should "just work."

An error page can be served from any location and therefore it is
impossable to pre-build an error page with correct relative URLs.
With absolute URLs, the error pages will properly link to other
pages in the nav as well as media files (css, js, images, etc) from
the template regardless of the actual URL the file is served from.

However, to continue to support environments where the docs root is a subdir
of the server root, all other pages must continue to use relative URLs.
The `site_url` is used to determine the server root when building
absolute URLs for the error page to ensure those URLs continue to work
in that type of environment.

Relative URLs are also nessecary for those who browse the site on the
local file system (via `file://`). In that case, the error page will be
broken. However, as error pages are not served by a local file system,
this is no more than a minor inconvience. Error pages should always be
tested from a server environment.

Fixes mkdocs#77.
@waylan

waylan commented Aug 29, 2016

Copy link
Copy Markdown
Contributor Author

I've added tests and release notes. If all the tests pass, this should be ready to go.

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.

1 participant