svnm
svnm

Reputation: 24398

In Jekyll is there an easy way to change an output path for a folder with html

I am using Jekyll for some static site templates and I have a folder of product html pages which I want to be bundled into the root site/ folder rather than into a site/products folder.

example below with just 2 product pages:

src folder

output to site

Is there an easy way to do this?

Additionally would there be an easy way to append products- to each file in this folder?

Upvotes: 0

Views: 1029

Answers (1)

Shadowen
Shadowen

Reputation: 834

Try looking into Jekyll collections. You'll specifically want the Permalink feature. Hopefully the following snippet will get you started.

config.yml

collections:
  products:
    output: true
    permalink: /product-:title/

source tree

_products
    |
    1.html
    2.html
    3.html
    ...

output tree

_site
    |
    product-1
        |
        index.html
    product-2
        |
        index.html
    product-3
        |
        index.html
    ...

This creates the "pretty permalinks" structure where file endings are removed by using index.html within a directory of the correct name. Of course you could set it to create the "ugly permalinks" (project-1.html, etc), but I like this style more.

Upvotes: 1

Related Questions