Lego2012
11/23/2016 - 4:11 PM

site.url and site.baseurl

site.url and site.baseurl

<!-- 
When creating sites and themes, there's a lot of confusion around site.url and site.baseurl. These new filters attempt to unify the way we calculate relative and absolute URL's. The new filters are:

relative_url - takes a URL and returns a url with site.baseurl properly prepended. This is useful when you want to be host-agnostic.
absolute_url - takes a URL and returns a url with site.baseurl and site.url properly appended.

<!--
Examples, assuming site.baseurl = "/project" and site.url = "http://example.com": 
-->

<!-- "/project/css/main.scss" -->
{{ "/css/main.scss" | relative_url }}

<!-- "http://example.com/project/css/main.scss" -->
{{ "/css/main.scss" | absolute_url }}