include_relative post.path jekyll - jekyll

I'm trying to put a number of related posts on a single page. The problem is that the included posts are all textile pages, using some {% highlight %} tags. When I try to include then via post.content, they don't get textilized (e.g, I see "{% highlight..." on the page).
I've tried a few different things:
This never gets textilized:
{% for post in site.tags.my_tag %}
{{ post.content | textilize }}
{% endfor %}
This (based on http://nateeagle.com/2011/08/31/jekyll-not-parsing-includes/) returns no content:
{% for post in site.tags.apidocs %}
{% capture included_post %}
{{% include_relative post.path %}}
{% endcapture %}
{{ included_post | textilize }}
{% endfor %}
Any ideas?
Bradley

Try
{% include_relative {{post.path}} %}

Related

Jekyll/Liquid Relative URL filter breaks links

I'm trying to use relative_url in most of the links of my Jekyll theme, so if someone wants to have this theme working in a subdirectory he can do it.
I have a problem with the list of categories of the post, each of which should link to the archive.
In _layouts/post.html I have this code:
{% if site.data.settings.categories.active %}
{% include categories.html %}
{% endif %}
categories.html has this code:
<div class="categories">
<span><p>Categories:</p>
{% if post %}
{% assign categories = post.categories %}
{% else %}
{% assign categories = page.categories %}
{% endif %}
{% for category in categories %}
{{category}}
{% unless forloop.last %} {% endunless %}
{% endfor %}
</span>
</div>
Here's the problem:
{{category}}
Somehow, this returns the current post url.
{{category}}
This returns the correct link, but does not work in case the site is in a subdirectory.
Why it returns the post url?
There are multiple problems here.
First off, Liquid doesn't evaluate nested constructs.
Therefore, the following code:
{{ "/categories/#{{category | slugify}}" | relative_url}}
needs to be rewritten into:
{% capture url %}/categories/{{ category | slugify }}{% endcapture %}
{{ url | relative_url }}
Secondly, there is no global post object. Therefore {% if post %} is always going to evaluate to a negative. i.e., it is redundant.

how to displayliquid code in Jeckyll post

Hello I am trying to make a post using jeckyll and as part of my post I would like to show some liquid code. The post should display the IF statement as part of the post text (example below).
{% if customer and customer.tags contains 'Wholesale' %}
{% endif %}
I have tried to post this as
{% highlight liquid %}
{% if customer and customer.tags contains 'Wholesale' %}
{% endif %}
{% endhighlight %}
and also
{% highlight markdown %}
{% if customer and customer.tags contains 'Wholesale' %}
{% endif %}
{% endhighlight %}
but anything I try seems to be still executing the liquid code.
Is there a way to display the IF statement my post?
Try wrapping your liquid code in {% raw %} {% endraw %} like this:
{% highlight liquid %}
{% raw %}
{% if customer and customer.tags contains 'Wholesale' %}
{% endif %}
{% endraw %}
{% endhighlight %}
The raw tag will disable any liquid processing and output your code as desired.

Include the whole post, not only summary. Jekyll

I have a very noob question. I want to create a page, where will be presented all posts from some category. I understand, that I should write some {% include %} tag, but I could not understand which.
I have:
{% for post in site.posts %}
<!-- check if post comes from one of page categories-->
{% assign PostAndPageCategories= page.categories | concat: post.categories %}
{% capture all_cat %}{{ PostAndPageCategories | join: "," }}{% endcapture %}
{% capture unique_cat %}{{ PostAndPageCategories |uniq | join: "," }}{% endcapture %}
{% if all_cat != unique_cat %}
<!-- END check if post comes from one of page categories-->
{% include archive-single.html %}
{% endif %}
{% endfor %}
Obviously, this code shows me posts with teasers, but I need to display the whole post.
How should I change line {% include archive-single.html %}?
I found {{post.content}} instead of {% include archive-single.html %} work fine for me.

Liquid markup sorting the output

I am trying to display a list of all articles using liquid markup. I've got this code which displays them properly, however I want to be able to sort by the modified date descending (most recent article on top). How can this be accomplished?
I was thinking that perhaps I need to create a new array with all articles in it and then sort that, but I am not sure how to do that. Also note that I want to sort ALL of my articles by date, not just within each folder.
{% for category in portal.solution_categories %}
{% if category.folders_count > 0 %}
{% for folder in category.folders %}
{% for article in folder.articles %}
{{ article.title }} - {{ article.modified_on | short_day_with_time }} <br>
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}
Thanks!
You can use a variable to sort the list of articles and then iterate that variable.
{% for category in portal.solution_categories %}
{% if category.folders_count > 0 %}
{% for folder in category.folders %}
{% assign sorted = (folder.articles | sort:date) %}
{% for article in sorted %}
{{ article.title }} - {{ article.modified_on | short_day_with_time }} <br>
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}

include.param as the Foo in site.tags.Foo

I use the following code in _includes/last_two_foo_posts.html to display the title of the last two Jekyll posts which have the tag "Foo":
{% assign posts = site.tags.Foo %}
{% for post in posts limit:2 %}
{{ post.title }}
{% endfor %}
I'd like to refactor the code so that I can call the include with a
{% include last_two_posts.html param="Foo" %}
Is there a way in Liquid to use something like {{ include.param }} for the Foo in the site.tags.Foo code?
_includes/post_by_tag.html
{% assign posts = site.tags.[include.tag] %}
{% for post in posts limit: include.number %}
<p>{{ post.title }}</p>
{% endfor %}
using it
{% include post_by_tag.html tag='Rails' number=3 %}
Et hop !