zx_wing
zx_wing

Reputation: 1966

Jekyll: How to make it not to create sub-folder for each page?

My Jekyll root folder is like:

   site_root/
        |_______ tutorials/
                    |________ index.html
                    |________ tutorial1.md

however, after building, it generates a sub-folder for tutorial1.md as:

_site/
   |______ tutorials/
               |_______ index.html
               |________ tutorial1/
                             |_______ index.html

how can I make it not to generate the sub-folder but the plain page tutorial1.html?

Upvotes: 1

Views: 128

Answers (3)

user2189331
user2189331

Reputation:

By default Jekyll creates a folder structure of /some-title/index.html for a permalink style of (for example) permalink: /:title. To achieve a sane folder structure with friendly permalinks, install jekyll-clean-urls (which handles this specific case) or a similar plugin. That will produce a folder structure like this:

/some-title.html

Or for a permalink style of /:categories/:title:

/some-category/some-title.html

...getting rid of the wasteful folder structures. The basic plugin logic is straightforward. Example from sources:

def destination_with_clean_urls(dest)
  path = destination_without_clean_urls(dest)
  path.sub!(/\/index.html$/, '.html') if clean_urls?(permalink)
  path
end

You can then rely on MultiViews, mod_rewrite, or similar apparatus such that requests for /some-title or /some-category/some-title map to some-title.html. I'm using this myself in production (see profile website) and it's been solid thus far.

Upvotes: 2

David Jacquel
David Jacquel

Reputation: 52809

Can be a permalink: tutorial1/ in the page front matter. In this case remove it, or change it to permalink: tutorial1.html.

or

A 'permalink: pretty' set in _config.yml. In this case change to 'permalink: none'

Upvotes: 1

Madhur Ahuja
Madhur Ahuja

Reputation: 22681

I believe it has to do with relative_permalinks in your _config.yml. Try inverting its value.

You did not specify Jekyll version. Check out:

http://jekyllrb.com/docs/upgrading/

Upvotes: -1

Related Questions