I want to display some pages of my Jekyll website in my Home page. How can I accomplish this?
Currently I am trying to do the following:
{% assign sorted = (site.pages | sort: 'order_home') %}
{% for my_page in sorted %}
{% if my_page.order_home %}
{{ my_page }}
{% endif %}
{% endfor %}
However, what happens is that content is exhibited in the following form:
{"layout"=>"page", "title"=>"Blog", "permalink"=>"/blog/", "comments"=>false, "order_nav"=>4, "order_home"=>3, "content"=>"
\n{% for category in site.categories reversed %}\n
\n {% capture category_name %}{{ category | first }}{% endcapture %}\n
\n\n
{{ category_name }}
\n \n {% for post in site.categories[category_name] %}\n
\n
{{post.title}}
\n
\n {% endfor %}\n
\n{% endfor %}\n
\n", "dir"=>"/blog/", "name"=>"posts.md", "path"=>"posts.md", "url"=>"/blog/"}
I would like to make the content appear as if it was the rendered page itself, with the {{...}} blocks correctly processed. Any idea on how to do this?
Thanks!
Just add .content to my_page. This results in the following code:
{% assign sorted = (site.pages | sort: 'order_home') %}
{% for my_page in sorted %}
{% if my_page.order_home %}
{{ my_page.content }}
{% endif %}
{% endfor %}
Related
I am creating an archive by date and using this solution.
I want to add the category of the post next to the post and am having trouble capturing the category name of a post since categories are indexed through the site
{% else %}
<li>{{ post.title }}
{% capture category_names %}{{ ## need to capture category }}{% endcapture %}
{% if category_name %} - {% for category in category_names %}
{{category}}
{% unless forloop.last %} {% endunless %}
{% endfor %}
{% endif %}
{% if post.date %} - {{ post.date | date: "%m/%d/%Y" }}{% endif %}</li>
{% endif %}
Currently the code above creates {post name } - - mm/dd/YYYY as I want without the category name in between the 2 '-'.
Any idea how to capture the category name of a post? Thank you.
On my blog, I have a debug page which lists several things, including all the properties for each page in site.pages, like so:
{%- for page in site.pages -%}
<strong>{{ page.path }}:</strong><br>
<table>
{% for key_value in page %}
{% if key_value[0] == "content" %}
<tr><td>content</td><td>[{{ key_value[1] | size }} characters]</td></tr>
{% else %}
<tr><td>{{ key_value[0] }}</td><td><span>{{ key_value[1] }}</span></td></tr>
{% endif %}
{% endfor %}
</table>
{%- endfor -%}
This produces output like this:
So far, so good.
Now, I want to do the exact same thing with site.posts, but it doesn't work.
In particular, key_value[0] and key_value[1] don't have any value. The iteration does produce something, but it is not a key an value.
For example, the following produces a list of key names:
{%- for pp in site.posts -%}
<strong>{{ pp.path }}:</strong><br>
{% for kv in pp %}
{% capture cap %}{{ kv }}{% endcapture %}
<div>{{ cap }}</div>
{% endfor %}
<br>
{%- endfor -%}
like so:
I can't seem to get the content of the properties in a generic way, however. I guess the type of the things in the site.posts is not the same as sites.pages, in particular not a simple liquid dictionary.
I've tried messing around with to_liquid mentioned here without luck.
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.
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 %}
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}} %}