Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including metalsmith-hierarchy with all npm packages installed. Try it out:

var metalsmithHierarchy = require("metalsmith-hierarchy")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

metalsmith-hierarchy v0.1.0

Metalsmith plugin that adds hierarchy information to file metadata.


Metalsmith plugin that adds hierarchy information to file metadata. Uses file metadata parent property to crawl until a file with no parent is found, the list is output to the hierarchy property with the root node first and the current node last.

Advice / Rant

It's a bit laborous to add parent properties to a large amount of pages (something like blog posts), a plugin like metalsmith-filemetadata, for batch editing metadata is prefered over weird plugin only logic inside of this plguin.

When using this plugin, beware that the hierarchy property is inherently cyclical so be careful while using plugins that serializes file metadata like metalsmith-writemetadata.


$ npm install metalsmith-hierarchy --save-dev

Javascript Usage

Pass to `Metalsmith#use.

var hierarchy = require('metalsmith-hierarchy');




slug: archive


slug: post
parent: archive.html



slug: post
parent: archive.html
hierarchy: [
  { archive.html metadata },
  { post.html metadata },


There currently no options, any suggestions or pull-requests will be considered.


MIT 2015


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free