liquid

Sorted navigation menu with Jekyll and Liquid

流过昼夜 提交于 2019-11-28 03:14:49
I'm constructing a static site (no blog) with Jekyll/Liquid. I want it to have an auto-generated navigation menu that lists all existing pages and highlight the current page. The items should be added to the menu in a particular order. Therefore, I define a weight property in the pages' YAML: --- layout : default title : Some title weight : 5 --- The navigation menu is constructed as follows: <ul> {% for p in site.pages | sort:weight %} <li> <a {% if p.url == page.url %}class="active"{% endif %} href="{{ p.url }}"> {{ p.title }} </a> </li> {% endfor %} </ul> This creates links to all existing

Jekyll display posts by category

≯℡__Kan透↙ 提交于 2019-11-28 03:02:17
scratching my head over this - help much appreciated. I want to display a list of all my Jekyll posts, organised by category. I know Line 3 isn't correct but I can't figure out what it should be. Any ideas? Thanks! {% for category in site.categories %} <h3>{{ category | first }}</h3> {% for post in page.categories.category %} {{ post.title }}<br> {% endfor %} {% endfor %} Alex G Got it! Needed an intermediate posts loop before listing out individual posts <ul> {% for category in site.categories %} <li><a name="{{ category | first }}">{{ category | first }}</a> <ul> {% for post in category.last

How does Jekyll date formatting work?

让人想犯罪 __ 提交于 2019-11-27 17:55:38
I'm using Jekyll to generate a simple site. I want the date field to display in the format 12 September 2011 . I've found, through some creative googling, a bit of date-format manipulation, but nothing that seems to get me the month name. What I have is {{ page.date| date: "%m-%d-%Y" }} , which gets me output as 09-12-2011 , but isn't quite what I'm looking for. Is there any way to get the month as a name in Jekyll? Or, barring that, is there any documentation for the date attribute? Solution This output filter: {{ page.date | date: "%-d %B %Y" }} produces dates formatted like: 9 September

Escaping double curly braces inside a markdown code block in Jekyll

♀尐吖头ヾ 提交于 2019-11-27 17:39:58
I'm using Jekyll to create a documentation site wherein I am trying to document some code that contains handlebars-like syntax. For example {{foo}} . The problem is that Jekyll uses liquid tags and no matter what I do, my double curlies are getting ripped out by the liquid processor. By the way, I'm using kramdown as the markdown processor. Here is something I've tried: {% highlight html linenos %} Hello, my name is {{name}}. {% endhighlight %} This one removes the {{name}} section completely because it thinks it's a reference to a liquid variable. I also tried this: {% highlight html linenos

using Liquid variables inside of a liquid tag call

一个人想着一个人 提交于 2019-11-27 15:00:46
I made a custom link tag in Liquid and I am trying to be able to pass liquid variables into the call for that tag like so {{ assign id = 'something' }} // this value is actual dynamic while looping through data {% link_to article: id, text: 'Click Me!' %} // my custom tag However this results in the article parameter being passed in as 'id' instead of 'something' as per the assign statement above it. Does anyone know how to pass variables into tag calls? I've recently solved this very simply with Jekyll 0.11.2 and Liquid 2.3.0 by passing the name of the variable as the tag parameter. {% assign

Excluding page from Jekyll navigation bar

佐手、 提交于 2019-11-27 14:44:15
问题 I am setting up a basic Github-hosted Jekyll website (so minimal, I am not even bothering to change the default theme). I have a nested site with a small number of first-tier pages that I would like to appear in the navigation bar (i.e. the default mode of operation). I also have some second-tier pages that I would like to NOT junk up the navigation bar. While a multi-level navigation system would be nice, I'm trying to avoid using plugins. Therefore, I believe the simplest solution is to

What are some good ways to implement breadcrumbs on a Jekyll site?

人走茶凉 提交于 2019-11-27 14:01:06
问题 I'm aware that there are single-level breadcrumbs in http://raphinou.github.com/jekyll-base/ but I'm looking for some good ways to have breadcrumbs on a Jekyll site when directories get to a depth of four or five levels . (Yes, I'm well aware that Jekyll is primarily a blogging engine and that perhaps I shouldn't use it for a general purpose website, especially with many directory levels. I'm also aware of http://octopress.org but haven't found a suitable plugin.) Based heavily on http:/

Getting a specific item from a collection in Jekyll

旧城冷巷雨未停 提交于 2019-11-27 13:48:08
问题 I'm rebuilding my company's current site in Jekyll and attempting to set up the structure around a content model using objects (files in a collection) that have attributes (key/value pairs in YAML front-matter). Simple conceptual stuff designed to demonstrate effective content modeling to my team. Anything on the site that gets reused becomes an object, with the type of object defined by the specific collection that contains its file. So, I have a "services" collection for services offered by

How to use multiple arguments in an if statement with Liquid

♀尐吖头ヾ 提交于 2019-11-27 12:43:30
问题 I want to use an if statement in Liquid with multiple conditionals. Something like: {% if (include.featured == "true" and product.featured == "true") or (include.featured == "false" and product.featured == "false") %} Multiple conditionals don't seem to work. Have I got the syntax wrong or can Liquid not handle this sort of if statement? 回答1: Unfortunately, Liquid has a poor implementation of boolean algebra. Using Liquid's operators and tags, here is a dirty way to achieve it: {% if include

Convert string to integer in Shopify Liquid?

落爺英雄遲暮 提交于 2019-11-27 11:08:41
问题 I just read this related answer: How can I convert a number to a string? - Shopify Design — Ecommerce University To convert a string to a number just add 0 to the variable: {% assign variablename = variablename | plus:0 %} Not super elegant but it works! Inelegant or not, the answer given there isn't working for me. What's the right way to do this? Are the Liquid docs really missing such basic answers or am I just not finding the right place to look? 回答1: Using assign with a math filter is