Closed enginpost closed 4 years ago
@enginpost You'll have to provide more information inorder to get support. Perhaps a link to your repository..?
Sorry - yes, @ashmaroli here is the repo of the site. I had not yet moved it to github yet. I am going to host this somewhere other than github. https://github.com/enginpost/epst
If you look into https://github.com/enginpost/epst/blob/master/_layouts/archive.year.html you can see that I have added two elements to the frontmatter:
These designate to the https://github.com/enginpost/epst/blob/master/_layouts/default.html whether or not the recent sidebar item and/or the topics sidebar items should be included in the sidebar of the page.
If you look at https://github.com/enginpost/epst/blob/master/_layouts/posts.html -for example- this has the same frontmatter elements and it works fine. I set them to true and I can see the content of the sidebar for each rendered post.
But in the case of https://github.com/enginpost/epst/blob/master/_layouts/archive.year.html it doesn't actually see those elements passed to default, so it renders nothing.
I wondered if I needed to add them under the _config.yml in the Jekyll-archives section but that doesn't seem to work. Am I doing something wrong?
one more note...
I added a new element in the front matter of https://github.com/enginpost/epst/blob/master/_layouts/archive.year.html :
fm_message: 'hello world'
When I tried to print that out at the bottom of the same layout page, it doesn't print the value of {{fm_message}}. I get the vibe that Archive Layout pages are not processing any front matter other than "layout".
I see. I think you have confused yourselves with Jekyll's front matter defaults feature.
The Jekyll Archives does not have specialized support for default front matter. However, the pages it generates have a dedicated type
attribute that you can utilize via Jekyll's front matter defaults feature.
Edit your config file as below:
jekyll-archives:
- recent: true
- topics: true
enabled:
- year
layouts:
year: archive.year
permalinks:
year: '/archive/:year.html'
+ defaults:
+ - scope:
+ type: year
+ path: ""
+ values:
+ recent: true
+ topics: true
I see. I think you have confused yourselves with Jekyll's front matter defaults feature. The Jekyll Archives does not have specialized support for default front matter. However, the pages it generates have a dedicated
type
attribute that you can utilize via Jekyll's front matter defaults feature.Edit your config file as below:
jekyll-archives: - recent: true - topics: true enabled: - year layouts: year: archive.year permalinks: year: '/archive/:year.html' + defaults: + - scope: + type: year + path: "" + values: + recent: true + topics: true
Yes- that was just a wild experiment. Shouldn't front matter within the year layout pass all of the front matter elements to the layout mentioned in the year layout front matter? SAid another way, if I create a front matter of 'fm_message' in the year layout but the year layout front matter also says "layout: default' - the default.html layout should be able to read the value by calling {{page.fm_message}} right?
The {{ page }}
object only contains data regarding the current page being rendered — in this case, the archive page.
Since archive pages are generated at runtime, you can only supplement their front matter via the config file.
If you want to access layout data, you'll have to use the {{ layout }}
object instead.
Therefore, to test for value of fm_message
defined in the front matter of archive.year.html
layout in the parent layout default.html
, you need to use {{ layout.fm_message }}
in default.html
.
The
{{ page }}
object only contains data regarding the current page being rendered — in this case, the archive page. Since archive pages are generated at runtime, you can only supplement their front matter via the config file.If you want to access layout data, you'll have to use the
{{ layout }}
object instead. Therefore, to test for value offm_message
defined in the front matter ofarchive.year.html
layout in the parent layoutdefault.html
, you need to use{{ layout.fm_message }}
indefault.html
.
@ashmaroli thanks! That is exactly what I needed!
It feels like not all of the frontmatter is being respected in the archive pages. For example, I have two elements of front matter. Everywhere else on the site I can read those frontmatter elements. But I cannot from the archive page Year layout. When I attempt to print them out, it displays nothing.