pub fn derive_page_url(base_url: &str, relative_output_path: &str) -> StringExpand description
Joins a site base_url and a page’s site-relative output path
into the canonical absolute URL for that page.
Conventions (see module docs for the full table):
- a trailing slash on
base_urlis tolerated (no//is emitted); index.htmlat any depth collapses to the enclosing directory URL with a trailing slash — the pretty-URL form the Atom feed (src/plugins/postprocess/atom.rs) already publishes;\separators are normalised to/(Windows builds);- leading
.///on the relative path are ignored; - percent-encoding is passed through as-is.
§Examples
use ssg::urls::derive_page_url;
// Root page.
assert_eq!(
derive_page_url("https://example.com", "index.html"),
"https://example.com/"
);
// Pretty directory URL for a nested page.
assert_eq!(
derive_page_url("https://example.com/", "posts/foo/index.html"),
"https://example.com/posts/foo/"
);
// Non-index outputs keep their file name.
assert_eq!(
derive_page_url("https://example.com", "feed.xml"),
"https://example.com/feed.xml"
);