html pages turn into directories containing index.html files when compiled

7 views
Skip to first unread message

tenable

unread,
Oct 26, 2009, 9:18:33 PM10/26/09
to nanoc
Just started using Nanoc and it's great, fits the bills nicely!

Question: why does my html pages in /content compile into directories
containing an index.html file (except for my index.html file)?

Example:
/content/customer_service.html # compiles into => /output/
customer_service/index.html

Denis Defreyne

unread,
Oct 27, 2009, 3:40:54 AM10/27/09
to na...@googlegroups.com
On 27 Oct 2009, at 02:18, tenable wrote:

> Question: why does my html pages in /content compile into directories
> containing an index.html file (except for my index.html file)?
>
> Example:
> /content/customer_service.html # compiles into => /output/
> customer_service/index.html

Hi,

The reason why nanoc creates directories with "index.html" files by
default is because it results in pretty URLs. For example, my about
page is at http://stoneship.org/about/, and not at, for example, http://stoneship.org/about.html
, which is harder to remember and doesn't look as pretty.

You can customize this behaviour, though. You probably already have a
routing rule for '*' that looks like
route '*' do
item.identifier + 'index.html'
end
and therefore turns an item with identfier "/foo/bar/" into a path "/
foo/bar/index.html". If you want to make it output "/foo/bar.html"
instead, you can change the route to something like
route '*' do
item.identifier.chop + '.html'
end

Hope this helps!

Regards,

Denis

--
Denis Defreyne
denis.d...@stoneship.org

tenable

unread,
Oct 27, 2009, 10:35:36 AM10/27/09
to nanoc
Oh dang, didn't mean to post this thread twice!

On 27 Oct, 00:40, Denis Defreyne <denis.defre...@stoneship.org> wrote:

> The reason why nanoc creates directories with "index.html" files by
> default is because it results in pretty URLs.

That makes sense. Originally, I just wanted my pages to be in the root
of my site, so I came up with this:

route '*' do
if item.identifier == '/'
item.identifier + 'index.html'
else
'/' + item.identifier.gsub('/','') + '.html'
end
end

But I'm going to study your site a little bit more and I might go back
to the default behavior.

Anymore example sites out there besides stoneship, myst online and
h3rald?


Denis Defreyne

unread,
Oct 27, 2009, 10:42:24 AM10/27/09
to na...@googlegroups.com
On 27 Oct 2009, at 15:35, tenable wrote:

> Anymore example sites out there besides stoneship, myst online and
> h3rald?

Well, there is the nanoc site itself too, of course: <http://projects.stoneship.org/hg/sites-nanoc/
>. No other example sites, but I think four is already quite a bit. :)

Reply all
Reply to author
Forward
0 new messages