0

I'm stuck with this problem. When I use Markdown + Nunjucks as explained in the metalsmith-in-place Wiki the output is wrong (see below).

The default layout, note the safe filter (_layouts/base.njk):

<!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>{{title}}</title>
  </head>
  <body>
    {{ contents | safe }}
  </body>

The template that is using Markdown + Nunjucks (about.md.njk):

---
title: About
layout: base.njk
---

# {{ title }}

Output:

<p>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
    &lt;title&gt;About&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;</p>

<h1>About</h1>

<p>  &lt;/body&gt;
&lt;/html&gt;</p>
gremo
  • 47,186
  • 75
  • 257
  • 421

1 Answers1

1

Solved right after posting the question. This may be help, the problem is the order of plugins in my build.js:

Metalsmith(__dirname)
  .source('./contents')
  .destination('./build')
  .clean(true)
  .use(inPlace()) // inPlace must come BEFORE layouts!
  .use(layouts({
    directory: '_layouts',
    default: 'base.njk'
  }))
  .build(function(err) {
    if (err) throw err;
  });
gremo
  • 47,186
  • 75
  • 257
  • 421
  • Cool - just so no one else runs into this in the future, having that information live on SO is not as valuable as filing an issue (or even PR) to get the maintainer(s) to update the README.md to make that super explicit. Worth doing? – Mike 'Pomax' Kamermans Apr 13 '19 at 16:04
  • I'd suggest you might want to explain why this works. Would help those who come afterwards. – James Khoury Apr 14 '19 at 22:41