Reputation: 15996
I have an issue using scopes in my _config.yml
file:
In a multilingual blog, I want to use a given layout for all posts, and then customize permalinks for each language with a more specialized scope. Here is my configuration:
defaults:
-
# defaults for all files in the project
scope:
path: ""
values:
layout: my-page-layout
-
# defaults for all posts in the project
scope:
path: ""
type: posts
values:
layout: my-post-layout
-
# defaults for all english posts in the project
scope:
path: en
type: posts
values:
permalink: /en/:year/:month/:title/
-
# defaults for all french posts in the project
scope:
path: fr
type: posts
values:
permalink: /fr/:year/:month/:title/
English posts under the path en
effectively have the right layout (my-post-layout
), but not the french posts under the path fr
which have the default layout (my-page-layout
).
Looks like the scope corresponding to the pair "fr/posts" overrides the default values for all posts, while this is not the case for the scope corresponding to the pair "en/posts".
What am I missing?
EDIT:
The directory structure of my jekyll project looks like this (I removed unrelevant files):
./
├──_layouts/
│ ├──my-page-layout.html
│ └──my-post-layout.html
│
├──en/
│ ├──_posts/
│ │ └──2016-12-01-my-post-in-english.md
│ │
│ └──my-page-in-english.html
│
├──fr/
│ ├──_posts/
│ │ └──2016-12-01-mon-post-en-français.md
│ │
│ └──ma-page-en-français.html
│
└──_config.yml
Upvotes: 0
Views: 128
Reputation: 52829
Edit :
Reading from your code :
defaults:
-
scope:
path: ""
values:
layout: wasthishelpful-page
lang: en
-
scope:
path: fr
values:
lang: fr
-
scope:
path: ""
type: posts
values:
layout: wasthishelpful-post
-
scope:
path: en/_posts
values:
permalink: /en/:year/:month/:title/
-
scope:
path: fr/_posts
values:
permalink: /fr/:year/:month/:title/
And from jekyll code, we can see that we have a precedence problem.
The second rule applies to /fr path, but will not be overriden by third rule that applies to / path.
The solution is to declare your third rule before the second one by inverting them.
defaults:
-
scope:
path: ""
values:
layout: wasthishelpful-page
lang: en
-
scope:
path: ""
type: posts
values:
layout: wasthishelpful-post
-
scope:
path: fr
values:
lang: fr
...
Upvotes: 1