lukeorth / poison

Professional Hugo theme for dev bloggers. Based on Mdo's classic Hyde theme.
https://poison.lukeorth.com
GNU General Public License v3.0
198 stars 98 forks source link

Use Hugo Pipes for CSS/JS assets #90

Closed delroth closed 1 year ago

delroth commented 1 year ago

Poison currently ships JS/CSS files as statics instead of using Hugo's assets system ("Hugo Pipes", https://gohugo.io/hugo-pipes/). This has several drawbacks (sorted in my relative order of importance, most important first):

This PR migrates to Hugo Pipes and bundles/minifies CSS and JS at build time as much as possible. This moves a bunch of files around, but ultimately the required changes are pretty small, see layouts/** for the actually meaningful stuff.

You can see the results on my website: https://delroth.net/ which is currently running with my fork and includes this PR.

delroth commented 1 year ago

One thing to note: this does require theme users to move their CSS/JS overrides from static/{css,js}/* to assets/{css,js}/* to continue working. I don't know how you want to handle this kind of backwards-compatibility breaking changes in this project, please let me know if you want me to do anything in that regards!

delroth commented 1 year ago

Pagespeed results using this PR (+ a few other minor fixes that don't impact performance): https://pagespeed.web.dev/analysis/https-delroth-net/0wpg4jfttx?form_factor=desktop

out_000

lukeorth commented 1 year ago

Thank you, @delroth -- this is fantastic!

Bundling/minifying static assets has been on my to-do list for awhile. It's something that I knew needed to get done, but I hadn't read enough of the Hugo docs to get it working. This PR solves that, so thank you. :slightly_smiling_face:

lukeorth commented 1 year ago

One thing to note: this does require theme users to move their CSS/JS overrides from static/{css,js}/* to assets/{css,js}/* to continue working. I don't know how you want to handle this kind of backwards-compatibility breaking changes in this project, please let me know if you want me to do anything in that regards!

Regarding this, I plan to update the instructions for including custom CSS in the README. It will probably cause some confusion for those affected (at least initially), but the fix is simple enough that I think it can be highlighted in the docs without too much trouble.

Thank you for the heads up!