Foo.md being built as Foo/index.html?


#1

So I’ve got a Jekyll site, it has a file called CHANGELOG.md in it but when I get Jekyll to build the site, instead of getting CHANGELOG.html, I get a directory called CHANGELOG containing a file called index.html.

Why, please, and how can I get Jekyll to create CHANGELOG.html?

Thanks.


#2

OK … so it looks like this is (a) by design and (b) being triggered by the permalink behaviour:

When you use permalinks that omit the .html file extension (called “pretty URLs”) Jekyll builds the file as index.html placed inside a folder with the page’s name.

(https://jekyllrb.com/docs/permalinks/)

Testing has revealed that this is being triggered because the config file says:

permalink: /news/:title/

which omits the .html extension.

So, if I want CHANGELOG.html, is my only choice to put an overriding permalink in the front matter for that specific file, or is it possible to have another permalink defined in the config, e.g.:

permalink: title

so that this gets used if /news/ isn’t appropriate?

Updated: yes :). If I have:

permalink: /news/:title/
permalink: title

Then CHANGELOG.md gets as CHANGELOG.html.


#3

OK, so it turns out that this doesn’t work after all :frowning: Jekyll just uses the last defined permalink.

I’ll try putting

permalink: title

in the markdown for the individual pages. You can probably tell that I’m not particularly experienced at this :smiley:


#4

I’m giving up on this. I don’t seem to be able to come up with a permalink syntax for the file that can be generalised, e.g. taking the title and adding .html to it.

In other words, if I use something like:

permalink: :title.html

the page isn’t built but no errors are generated.

So I’m just going to leave the permalink out and let Jekyll go back to creating a directory with index.html inside it. I don’t like it but at least the site builds.


#5

What are you trying to accomplish? for posts you want one thing, for pages you want another? Is it just the changelog page?

I think you can set permalinks by path in the config via front matter defaults - thought I don’t see an example of it in the docs:

Did you read this section - posts are treated different than pages?


#6

@rdyar For the site I’m working on, most of the pages are being manually edited and have got their permalink manually set in each page.

There are a few pages that are being ingested from elsewhere so I have very limited control over what I can do by way of front matter. For those, I’m trying to find an automatic or templated way or setting the permalink, which is why I was trying to use the title approach.

Unfortunately, I don’t seem to be able to get much in the way of diagnostics out of Jekyll as to why it is refusing to build the pages when I’m trying out some of the ideas. It just doesn’t output the pages at all but doesn’t complain either.

I might see if I can do a bit more with altering the front matter on these files but it is tricky. As the moment, leaving it to no permalink at all does give me generated pages, just as a directory and a file rather than just as a file.


#7

I see you’ve tried permalink: :title.html, but have you tried it with a forward slash?

permalink: /:title.html

This should give you /CHANGELOG.html or whatever the post/page’s title is .html


#8

I think I had tried that previously and just not noted it in this thread.

That said, I have just tried it and I am back to the “no output generated, no errors reported” status.


#9

Only other suggestion I can offer is if you have a public repo we can look at to see exactly what’s going on with your _config.yml settings and page content.

You can also run try running the Jekyll serve and build commands with the --verbose flag enabled. It’ll show you more detail on the pages Jekyll is reading, writing, or skipping…

jekyll serve --verbose

You’ll see stuff like this in your terminal/console which may give you a clue what is the problem.

Generating...
       EntryFilter: excluded /Gemfile
       EntryFilter: excluded /Gemfile.lock
           Reading: _posts/2009-05-15-edge-case-nested-and-mixed-lists.md
         Rendering: _posts/2009-05-15-edge-case-nested-and-mixed-lists.md
  Pre-Render Hooks: _posts/2009-05-15-edge-case-nested-and-mixed-lists.md
  Rendering Liquid: _posts/2009-05-15-edge-case-nested-and-mixed-lists.md
  Rendering Markup: _posts/2009-05-15-edge-case-nested-and-mixed-lists.md