Help with Loop
Closed this issue ยท 9 comments
Hi! I've tried using this plugin, but can't figure out what the right post loop is.
This is the one I'm using:
{% if blog.category == 'blog' %}
<article class="blog-post-item"><a href="{{site.baseurl}}{{ blog.url }}">
<div class="blog-post-thumbnail" style="background: linear-gradient(0deg, rgba(0,0,0,0.70) 0%, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.50) 100%), url('{{site.baseurl}}/public/images/post-images/{{blog.image}}/thumbnail.jpg'); background-position: center center; background-size: cover">
<div class="content">
<div class="text">
<h2>{{ blog.title }}</h2>
<span>{{ blog.time }} min read</span>
</div>
</div>
</div></a>
<p>{{ blog.excerpt }}</p>
</article>
{% endif %}
{% endfor %}
Worth adding: I have seen the loop included in the readme, but I don't know how to go from my loop to that one ๐ข
Do you forget {% for post in paginator.posts %}
?
{% if page.paginator %}
{% assign paginator = page.paginator %}
{% endif %}
{% for post in paginator.posts %}
<article class="blog-post-item"><a href="{{site.baseurl}}{{ post.url }}">
<div class="blog-post-thumbnail" style="background: linear-gradient(0deg, rgba(0,0,0,0.70) 0%, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.50) 100%), url('{{site.baseurl}}/public/images/post-images/{{post.image}}/thumbnail.jpg'); background-position: center center; background-size: cover">
<div class="content">
<div class="text">
<h2>{{ post.title }}</h2>
<span>{{ post.time }} min read</span>
</div>
</div>
</div></a>
<p>{{ post.excerpt }}</p>
</article>
{% endfor %}
The part I don't understand is where do you put the category in that loop?
Or do you just put it in the _config.yaml file?
paginate: 5
paginate_path: "page:num"
category_dir: "blog"
category_layout: "index.html"
category_dir: "design"
category_layout: "/design/index.html"
Thanks for bearing with me :)
Oh, category_dir
and category_layout
is only once.
root/_config.yml
:
paginate: 5
paginate_path: "page:num"
category_dir: "categories"
category_layout: "index.html"
root/index.html
:
{% if page.paginator %}
{% assign paginator = page.paginator %}
{% endif %}
{% for post in paginator.posts %}
<article class="blog-post-item"><a href="{{site.baseurl}}{{ post.url }}">
<div class="blog-post-thumbnail" style="background: linear-gradient(0deg, rgba(0,0,0,0.70) 0%, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.50) 100%), url('{{site.baseurl}}/public/images/post-images/{{post.image}}/thumbnail.jpg'); background-position: center center; background-size: cover">
<div class="content">
<div class="text">
<h2>{{ post.title }}</h2>
<span>{{ post.time }} min read</span>
</div>
</div>
</div></a>
<p>{{ post.excerpt }}</p>
</article>
{% endfor %}
jekyll build
generates _site/categories/*
_site/categories
โโโ blog
โ โโโ index.html
โโโ design
โ โโโ index.html
Please read plugin for category loop :)
Gotcha, so it generates a page for each category.
Is there a way to have one of those 2 pages be the home page?
On Apr 20, 2016, 09:24 -0700, midnightSuyamanotifications@github.com, wrote:
Oh,category_dirandcategory_layoutis only once.
root/_config.yml:
paginate: 5 paginate_path: "page:num" category_dir: "categories" category_layout: "index.html"
root/index.html:
{% if page.paginator %} {% assign paginator = page.paginator %} {% endif %} {% for post in paginator.posts %}
{{ post.title }}
{{ post.time }} min read{{ post.excerpt }}
{% endfor %}jekyll buildgenerates_site/categories/*
_site/categories โโโ blog โ โโโ index.html โโโ design โ โโโ index.html
Please readplugin(https://github.com/midnightSuyama/jekyll-paginate-category/blob/master/lib/jekyll-paginate-category.rb#L13)for category loop :)
โ
You are receiving this because you authored the thread.
Reply to this email directly orview it on GitHub(#3 (comment))
Humm, I don't get it.
Isn't the _site/index.html
?
Yes. But I'm trying to get my home page to JUST show the 'design' category,
and have a separate page for the 'blog' category.
And no page where you could see both categories.
Thanks again for your help :)
**Arturo Goicochea / **@arturogoicochea
UX Designer: arturogoicochea.com
Photographer: arturo.photos
On Apr 20 2016, at 10:00 am, midnightSuyama <notifications@github.com>
wrote:
Humm, I don't get it.
Isn't the _site/index.html ?โ
You are receiving this because you authored the thread.
Reply to this email directly or [view it on
GitHub](#3 (comment)
suecomment-212514471)![](https://github.com/notifications/beacon/AGtIL1-pe4e9N
eWnQOrJo3W7DIzEF0_pks5p5luagaJpZM4ILE3L.gif)
Sorry, This plugin isn't cut out for your demand.
Thanks :)
So it seems... :(
Thanks for taking the time to help, really appreciate it.
**Arturo Goicochea / **@arturogoicochea
UX Designer: arturogoicochea.com
Photographer: arturo.photos
On Apr 20 2016, at 10:51 am, midnightSuyama <notifications@github.com>
wrote:
Sorry, This plugin isn't cut out for your demand.
Thanks :)
โ
You are receiving this because you authored the thread.
Reply to this email directly or [view it on
GitHub](#3 (comment)
suecomment-212533668)![](https://github.com/notifications/beacon/AGtIL9zveHO5v
jOtkLz8nrF_r8XUMwGyks5p5meggaJpZM4ILE3L.gif)