11ty / eleventy-plugin-template-languages

Official template syntax plugins for Eleventy
MIT License
2 stars 1 forks source link

Permalink path being encoded #5

Open colindresj opened 3 years ago

colindresj commented 3 years ago

Describe the bug If I set the permalink for a page (in any way) the output contains what looks like HTML.

For example, if I set the following on my src/404.pug:

---
permalink: 404.html
---

The following gets written:

Writing _site/<404 class="html"></404> from ./src/404.pug.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project and set set templateFormats to ['pug']
  2. Create a pug template with permalink set in the frontmatter
  3. Build
  4. See error

Expected behavior Expecting the following:

Writing _site/404.html from ./src/404.pug.

Environment:

binyamin commented 3 years ago

Thanks for reporting. I can reproduce this with any permalink. I'll look into it a bit.

binyamin commented 3 years ago

According to https://github.com/11ty/eleventy/issues/539#issuecomment-494776672, you need to enclose the value in quotes and prefix it with a pipe "|" character. The reason is that pug is trying to compile it as code.

It's still not expected behavior.

awmottaz commented 1 year ago

I ran into this same issue using WebC. The following source file causes an error on build:

404.webc

---
permalink: 404.html
---

In the WebC case, the fix is either to "double quote" the value, like this:

---
permalink: "'404.html'"
---

Or disable template processing of the permalink:

---
permalink: 404.html
dynamicPermalink: false
---
zachleat commented 1 year ago

@awmottaz I filed that separate WebC issue at https://github.com/11ty/eleventy-plugin-webc/issues/47

Thanks!

Alternatively the pug issue is still present in 2.0. Workaround is to use dynamicPermalink!