Unit 06 · lesson
`url` and `baseurl`
url and baseurl
This pair causes a lot of "works locally, breaks online" confusion.
So make the model explicit.
url
Think of url as the site's origin/domain portion for production URL generation.
Example:
url: "https://student.github.io"
baseurl
baseurl represents the subpath under which the site is served when it is not at the domain root.
Example project site:
baseurl: "/portfolio"
Production root:
https://student.github.io/portfolio/
Local development can hide the mistake
Your local preview may be served in a way that makes paths appear fine.
Then GitHub Pages exposes the missing repository subpath.
That is a configuration/deployment boundary.
Controlled configuration experiment
Temporarily set a non-empty baseurl in a disposable branch or local copy.
Build.
Inspect output from:
{{ '/about/' | relative_url }}
Compare with a hard-coded:
href="/about/"
Record the difference.
Do not concatenate URLs by hand everywhere
Central configuration + Jekyll URL filters give you one policy boundary.
Random string concatenation across templates creates dozens of assumptions.
Checkpoint
Draw:
url + baseurl + page path = intended production address
using your planned deployment values.