I found an example online which uses collections
and permalinks
, the code is like this:
Metalsmith(__dirname)
.use(collections({
pages: {
pattern: 'content/pages/*.md'
},
posts: {
pattern: 'content/posts/*.md',
sortBy: 'date',
reverse: true
}
}))
.use(markdown())
.use(permalinks({
pattern: ':collection/:title'
}))
.use(templates('handlebars'))
.destination('./build')
.build()
Which converts this file structure:
src/
index.md
content/
pages/
aboud.md
blog.md
posts/
first-post.md
To:
build/
index.html
content/pages/ (empty??)
pages/
about/ -> index.html
blog/ -> index.html
posts/
first-post/ -> index.html
Note that src/index.md
is converted, as well as the collections. But in 1.0.0
, the same code converts only the collections and throws an error for index.md
: Error: UNKNOWN, open '/home/index.html'
Any idea?