Can you use Jekyll page variables in a layout?
Tag : css , By : General Mills
Date : March 29 2020, 07:55 AM
it fixes the issue I'm using Jekyll for my blog, and I'd like the ability to use unique CSS styling in particular posts. Right now, I'm specifying a CSS file in the YAML frontmatter like so: , I'm pretty sure this would work: ---
title: xxx
style: |
/* You can put any CSS here */
/* Just indent it with two spaces */
/* And don't forget the | after "style: " */
h2 {
color: red;
}
---
Your markdown/textile goes here. h2s will be red
<style type="text/css">
{{ page.style }}
</style>
|
is possible to loop through yaml variables of jekyll page without knowing them?
Date : March 29 2020, 07:55 AM
hop of those help? When you loop on a Page (Page objects like index, about, ...) variables, you receive arrays like : {% for var in page %}
{{ var | inspect }} => ["layout", "default"]
{% for var in page %}
key-name : {{ var[0] }} , value : {{ var[1] }}
{% endfor%}
{% for var in page %}
key : {{ var }} , value : {{ page[var] }}
{% endfor%}
|
Parse liquid variables in YAML front matter in Jekyll before processing the page
Date : March 29 2020, 07:55 AM
Hope this helps It is not clear to me why the front matter should contain a variable. In most cases you do not need variables in the front matter. I think that this is also the case in your situation. I would move the front matter variable to the layout file. Thus, the layout file should look like this: <meta property="og:image" content="myBlog/{{ page.url }}/{{ page.image }}" />
---
image: "b.png"
---
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% if page.title %}{{ page.title }} | {% endif %}{{ site.title }}</title>
{% assign pagecontent_description = page.content | markdownify | replace: '.', '. ' | replace: '</h2>', ': ' | replace: '</h3>', ': ' | replace: '</h4>', ': ' | strip_html | strip_newlines | replace: ' ', ' ' | truncate: 160 %}
<meta name="description" content="{% if pagecontent_description.size > 10 %}{{ pagecontent_description }}{% else %}{{ site.description }}{% endif %}">
<link rel="shortcut icon" type="image/png" href="/img/icon-196x196.png">
<link rel="shortcut icon" sizes="196x196" href="/img/icon-196x196.png">
<link rel="apple-touch-icon" href="/img/icon-196x196.png">
<!-- Facebook and Twitter integration -->
<meta property="og:title" content="{{ page.title }}"/>
{% if page.image %}<meta property="og:image" content="{{ page.image }}"/>{% endif %}
<meta property="og:url" content="{{ site.url }}{{ page.url }}"/>
<meta property="og:type" content="article">
<meta property="og:image" content="{{ site.url }}{{ page.image }}"/>
<meta property="og:site_name" content="{{ site.title }}"/>
<meta property="og:description" content="{% if pagecontent_description.size > 10 %}{{ pagecontent_description }}{% else %}{{ site.description }}{% endif %}"/>
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@{{ site.twitter_url }}">
<meta name="twitter:title" content="{{ page.title }}" />
{% if page.image %}<meta name="twitter:image" content="{{ site.url }}{{ page.image }}" />{% endif %}
<meta name="twitter:url" content="{{ site.url }}{{ page.url }}" />
<meta name="twitter:description" content="{% if pagecontent_description.size > 10 %}{{ pagecontent_description }}{% else %}{{ site.description }}{% endif %}" />
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
<link rel="sitemap" type="application/xml" title="Sitemap" href="{{ "/sitemap.xml" | prepend: site.baseurl | prepend: site.url }}" />
|
Jekyll definition for site or page variables?
Date : March 29 2020, 07:55 AM
Hope that helps At the basic level, there are 5 kinds of data types in Jekyll. Pages Static files Documents Collections Data files ---
foo: bar
---
|
how do I concat page variables in jekyll loops
Date : March 29 2020, 07:55 AM
|