0

I generate HTML files without any filetype extension with the following route in nanoc’s Rules file:

route '/blog/*/' do
  item.identifier.chop
end

So the file /content/blog/hello-world.html gets generated as /output/blog/hello-world, leading to the URL path /blog/hello-world.

When using nanoc’s built-in preview server (nanoc view, which uses adsf and WEBrick, as far as I understand), these extension-less HTML files get interpreted as plain text.

For previewing with nanoc view, how can I set the default content type (i.e. text/html) for files without filetype extensions?

(When publishing this site, I set the correct content type in Apache’s .htaccess file so that the files get interpreted as HTML, but WEBrick/adsf don’t seem to support .htaccess.)

unor
  • 92,415
  • 26
  • 211
  • 360

1 Answers1

0

You should be writing those to /output/blog/hello-world/index.html instead. That makes them work seamlessly in nanoc view, Apache (with no .htaccess), even by just opening the site files in your browser (assuming you're using relativized links).

bobthecow
  • 5,047
  • 25
  • 27
  • Adding a file extension circumvents my problem, of course, but as stated in the question, I have (and want to have) HTML files without extension. Another, rather ugly, circumvention for some cases (but not in my case) could be to have extensions in nanoc, and use URL rewriting on the live server to remove those extensions again (as well as removing all `.html` extensions from internal links within nanoc before deploying). – unor Jan 02 '15 at 01:35
  • Writing files to `index.html` _does_ create URLs without file extensions, and without rewriting. That's how web servers work. – bobthecow Jan 03 '15 at 18:30