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

Support for custom data mapping #110

Open
mooperd opened this issue Jul 2, 2021 · 3 comments
Open

Support for custom data mapping #110

mooperd opened this issue Jul 2, 2021 · 3 comments
Labels
feedback waiting for feedback on the issue

Comments

@mooperd
Copy link

mooperd commented Jul 2, 2021

Hello,

Is it possible to use custom data mapping? For example I would like to be able to control other elements - specifically the subtitle, and perhaps show_sidebar which is part of the ??front matter??. Please excuse my ignorance - I'm very new to jekyll.

Right now subtitle: scenario seems to be ignored

page_gen:
- data: skill-sprints
  template: skill-sprint
  dir: skill-sprints
  index_files: false
  name: url
  title: name
  subtitle: scenario
---
title: Title Text
subtitle: Subtitle Text
layout: category
show_sidebar: false
---

Thanks,

Andrew

@jakubheglas
Copy link

+1 here! Specifically not being able to set description and other front matter SEO related items is very limiting.

@avillafiorita
Copy link
Owner

Hi -
thanks for the feedback. There is a workaround. I am not even sure it is an issue with the plugin.

More in details: substitution of liquid tags does not seem to be recursively applied. In other words: you can reference and use data fields directly in your layouts, but you cannot define a front-matter variable in a layout, based on a data field and have its content replaced in the layout. Hence if you use the data fields directly, you should be fine. (Detailed explanation below.)

Whether this is a bug of the plugin, a bug of Jekyll or a feature of both, to be honest, I can't tell.

Detailed Explanation

Consider the example directory and let us use a new layout:

- data: 'members'
  template: 'default'
  dir: 'metadata'
  name: 'full_name'

where _layouts/default.html= is.

<html>
  <head>
    <title>{{page.title}}</title>
    <meta author="{{page.full_name}}">
    <meta description="{{page.description}}">
  </head>
  <body>
    {{content}}
  </body>
</html>

Notice that the author field references a field in member.yml, while, at the moment, the description field does not reference any field. The generation works fine and the metadata is correctly generated, that is, we get:

[...]
<meta author="Adolfo Villafiorita">
[...]

The line referencing {{page.description}} will result in the empty string, since there is no description field in members.yml.

However, if we use one level of "indirection", that is, we define variables in the front-matter of a layout and try to use them in another layout, the liquid tags are not replaced.

That is, if:

- data: 'members'
  template: 'metadata'
  dir: 'metadata'
  name: 'full_name'

where _layouts/metadata.html is:

---
title: {{page.name}}
layout: default
description: Homepage of {{page.full_name}}
---
{{ content }}

Then we get the following:

[...]
<meta author="Adolfo Villafiorita">
<meta description="Homepage of {{page.full_name}}">
[...]

That is, {{description}} in default.html gets substituted with its value defined in metadata.html, but {{page.full_name}} in the definition of the description field does not.

@avillafiorita avillafiorita added the feedback waiting for feedback on the issue label Feb 8, 2022
@komputeks
Copy link

Anybody think of a way to solve this problem using this plugin

https://github.com/gemfarmer/jekyll-liquify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback waiting for feedback on the issue
Projects
None yet
Development

No branches or pull requests

4 participants