I have sass that creates a css file, and I an having trouble figuring out how to reference it in the html templates.
First I tried this
<link rel="stylesheet" href="main.css">
And it works great for everything in the root. I then made a template for a section. My content is nested in folders ( like /blog/post/index.html once rendered) and it can't find the css file anymore. So then I found a post about relative pathing which looked exactly what I was wanting, but after trying it I figured out its only for inside of markdown.
<link rel="stylesheet" href="./main.css">
So this doesn't work, well it works in the root files, but not in any of the post files.
Then I found the get_url function which looks like what I want, yet again, but this doesn't do exactly what I want.
<link rel="stylesheet" href="{{ get_url(path="main.css", trailing_slash=false) }}">
It seems to work fine, but that is because its referencing the absolute css from the website, but this doesn't work well for development. If I'm tweaking or editing the sass my desktop copy will not ever update because gutenberg build then references the remote website files and not the local files.
How can I get Gutenberg to give me a relative link in a template?
sass/main.scss => ./main.css (inside ./index.html)
./../main.css (inside ./posts/index.html)
I'm not sure what's the issue with get_url? I use that for assets (including Sass) in all my sites (for example the docs: https://github.com/Keats/gutenberg/blob/master/docs/templates/index.html#L10).
gutenberg serve automatically live reloads the css and is what should be used for development.
I have been using gutenberg build and it makes all the get_url paths to the website path and not the local path
<link rel="stylesheet" href="https://snsvrno.github.io/main.css">
not
<link rel="stylesheet" href="./../main.css">
Which means I don't see my sass tweaks until I publish and build it remotely.
I haven't used gutenberg serve because the first time I used it I had issues getting it to work right (I was trying to run it from a task inside VSCODE and it was created too many instances and they weren't being killed) so I just decided to use gutenberg make
I just tried gutenberg serve from a terminal and it worked fine, so I'll work using that moving forward.
I was trying to use gutenberg build for local development but I can't do that because it builds the paths assuming its on a webserver. I'd suggest a way to allow people who want to use gutenberg build in there development workflow to allow relative paths with get_url.
Though now I realize gutenberg serve fulfills my needs, I don't need it anymore.
Though now I realize gutenberg serve fulfills my needs, I don't need it anymore.
Cool!
Can we reopen this?
This is needed to publish sites for ipfs - the links must all be relative.
The config base_url = "./" works for everything except sass generated css file.
EDIT: Nevermind! It works! :grin:
Most helpful comment
Can we reopen this?
This is needed to publish sites for ipfs - the links must all be relative.
The config
base_url = "./"works for everything except sass generated css file.EDIT: Nevermind! It works! :grin: