Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Specify permalink pattern in template layouts #121

Closed
kleinfreund opened this issue May 12, 2018 · 4 comments
Closed

Feature: Specify permalink pattern in template layouts #121

kleinfreund opened this issue May 12, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@kleinfreund
Copy link
Contributor

I want to specify a permalink pattern in a template layout like this:

layout.njk:

---
permalink: "{{ page.fileSlug }}/index.html"
---
{{ layoutContent | safe }}

Then, templates in ./content using the layout template from above (i.e. layout.njk) would all end up with transformed permalinks:

BEFORE: ./content/2017-09-03-example.md → _site/content/2017-09-03-example/index.html
AFTER:  ./content/2017-09-03-example.md → _site/example/index.html

This is different from the current behavior which only allows setting the permalink on regular templates but not layout templates (if I’m not mistaken). Currently, you would need to set the same permalink pattern (i.e. permalink: "{{ page.fileSlug }}/index.html") on all templates to achieve the above.

@kleinfreund kleinfreund changed the title Feature: Specify permalink in template layout Feature: Specify permalink pattern in template layouts May 12, 2018
@zachleat zachleat added the bug label May 13, 2018
@zachleat zachleat self-assigned this May 13, 2018
@zachleat zachleat added this to the Next Minor Version milestone May 13, 2018
@kleinfreund
Copy link
Contributor Author

kleinfreund commented Jun 15, 2018

This appears to not be fixed. The document for test 1 below should produce the same permalink style as instructed in the layout file, but it doesn’t.

./_includes/layouts/content.njk:

---
layout: layouts/base.njk
permalink: "{{ page.fileSlug }}/index.html"
---
{{ layoutContent | safe }}

./content/content.json:

{
  "layout": "layouts/content.njk"
}

./content/2000-01-01-test-1.md:

Test 1

→ produces ./_site/content/2000-01-01-test-1/index.html

./content/2000-01-01-test-2.md:

---
permalink: "{{ page.fileSlug }}/index.html"
---
Test 2

→ produces ./_site/test-1/index.html

@kleinfreund
Copy link
Contributor Author

kleinfreund commented Jun 15, 2018

However, it works when adding the instruction to the directory-specific data file like this:

./content/content.json:

{
  "layout": "layouts/content.njk",
  "permalink": "{{ page.fileSlug }}/index.html"
}

Correct if I’m wrong, but both should be equivalent, right?

@zachleat
Copy link
Member

Hmmmmmm

yes, I think so. Reopening.

@zachleat zachleat reopened this Jun 18, 2018
@zachleat zachleat removed this from the v0.3.5 milestone Jun 18, 2018
@zachleat
Copy link
Member

So there were tests around this but not using template/dir data files—which was the edge case we were missing.

This will be included with 0.3.7.

@zachleat zachleat added this to the Next Minor Version milestone Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants