0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

metalsmith-permalinksの紹介

0
Last updated at Posted at 2015-03-08

metalsmith-permalinks

静的サイトジェネレーター(static site generator)Metalsmithのプラグイン。
github:https://github.com/segmentio/metalsmith-permalinks

できること

about.html(もしくはabount.md)をビルドして、about/index.htmlのようにしてくれる。

metalsmith-permalinksによって、HTMLのリンク先が変わってしまうので、
それらはmetalsmith-collectionsを併用して、リンクを貼る。
※metalsmith-permalinksを使った際のハイパーリンク - Qiitaで解説

この記事の対象者

Metalsmithをビルドまではしたことがある人
ない人はMetalsmith(静的サイトジェネレーター)の導入 - Qiita

やり方

1. metalsmith-permalinksのnode-moduleをインストールする

# MetalsmithのProjectのディレクトリ内で、npm install
npm install metalsmith-permalinks --save-dev

2. metalsmith.jsonに指定して、適用する

metalsmith.json
{
  "metadata": {
    "title": "My Blog",
    "description": "My second, super-cool blog."
  },
  "plugins": {
// ...略...
    "metalsmith-permalinks": {
      "pattern": "posts/:title" // about.htmlのYAML Front-Matterに指定したフィールド名を:hogehogeのように利用出来る
    },
    "metalsmith-templates": {
      "engine": "handlebars"
    }
  }
}

3. ビルド

ビルドすると、生成物のディレクトリ(デフォルトはbuild)に、permalinkを貼れている生成物があるはず。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?