0

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

  • src/products/123.html
  • src/products/146.html

output to site

  • site/123.html
  • site/146.html

Is there an easy way to do this?

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

  • site/product-123.html
  • site/product-146.html
4

1 に答える 1

1

Jekyllコレクションを調べてみてください。特にパーマリンク機能が必要です。うまくいけば、次のスニペットで開始できます。

config.yml

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

ソースツリー

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

出力ツリー

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

index.htmlこれにより、正しい名前のディレクトリ内を使用してファイルの末尾が削除される「きれいなパーマリンク」構造が作成されます。もちろん、「醜いパーマリンク」(project-1.htmlなど)を作成するように設定することもできますが、私はこのスタイルがより好きです。

于 2015-08-06T02:20:50.550 に答える