Re: [nanoc] CSS read locally, ignored when uploaded

8 views
Skip to first unread message

Denis Defreyne

unread,
Aug 11, 2019, 6:46:32 AM8/11/19
to na...@googlegroups.com
Hello Tom,

If you open the HTML files directly in your browser, the references to the CSS files won’t be resolvable by the browser, because it’ll try to load /css/styles.css etc from the root of your hard drive, rather than relative to the HTML file itself.

You have two options for handling this:

* Use `nanoc view`, which will spin up a web server on your local machine, serving the Nanoc site. If you open the URL (printed in the console), the references will be correct.

* Use the `relativize_paths` filter, which will turn all references to relative ones. For HTML files, you’ll need `filter :relativize_paths, type: :html`, and for CSS, you’ll need `filter :relativizepaths, type: :css`. This is also useful in the case that you want to host the site inside a sub-directory somewhere. See the relativize_paths filter documentation for details.

Hope this helps!

Denis

On Tue, Jul 30, 2019 at 5:55 AM Tom Cloyd <tomclo...@gmail.com> wrote:
I am surely missing something simple here, simply because I don't do this work often enough to hang onto all the details.

My main "default.html" layout file contains these lines.
.
.
.
  <!-- template CSS -->
  <link rel="stylesheet" href="/css/styles.css" />
  <!-- custom CSS -->
  <link rel="stylesheet" href="/css/custom.css" />
  <link rel="stylesheet" href="/css/callouts.css" />
.
.
.

I see no problem in my /output dir after compilation. Checking the obvious, my three *.css files, newly compiled, are on the server. And they are referred to in my compiled site page files, exactly as indicated in the lines from my layout file above.

Inspecting the page in my browser, however, the CSS is clearly not there.

Someone please tell me what really dumb thing I'm doing that I can't see.

Thank you!

[Using Firefox 68.0.1, on LinuxMint 19.1]




--
You received this message because you are subscribed to the Google Groups "nanoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nanoc/50c8260f-da13-4777-a694-e95eb01ed008%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages