Postleaf / postleaf

Simple, beautiful publishing with Node.js.
https://www.postleaf.org/
MIT License
504 stars 204 forks source link

Make all URLs absolute #46

Closed lukewatts closed 7 years ago

lukewatts commented 7 years ago

At the moment many of the URLs are relative in Postleaf .i.e /themes/empower-theme/css/styles.css

There are some performance improvements by having absolute URLs instead. http://website.com/themes/empower-theme/css/styles.css

Essentially the browser has less work to do to locate files with absolute URLs vs relative URLs.

claviska commented 7 years ago

To clarify, Postleaf uses root-relative URLs (e.g. /path/to/file.ext) as opposed to relative URLs (e.g. 'path/to/file.ext`), so the browser simply prepends the hostname, which doesn't incur a performance hit.

The reason I'm using root-relative URLs is because it makes stored content and backup files more portable. You can effortlessly clone the site and move it between dev/staging/production and you only need to modify a single .env file.

I'm closing this since storing absolute URLs doesn't provide any obvious benefit, but does make things more difficult. For example:

Even if there were a performance hit, it would be on the client-side. In this type of app, it would be negligible. 🙂

lukewatts commented 7 years ago

I see you're point about portability. Hadn't thought of that.