Creating a second blog page

I’d like to have two pages with lists of posts. Currently the blog page is being populated ok, but the other page is not being populated even though I’ve set them up the same way.

I don’t understand why the posts on the page I’m trying to create don’t populate.

Is blog a keyword or something?

I’ve copied the structure of the blog page.

navigation

main:
  - title: "-"
    url: /portfolio/

  - title: "Blog"
    url: /blog/

I have a folders containing posts:

  • _blog
  • _portfolio

blog.html:

---
layout: archive
title: ""
permalink: /blog/
author_profile: false
---

{% include base_path %}


{% for post in site.posts %}
  {% include archive.html %}
{% endfor %}

portfolio.html

---
layout: archive
title: ""
permalink: /portfolio/
author_profile: false
---

{% include base_path %}


{% for post in site.portfolio %}
  {% include archive.html %}
{% endfor %}

in my _config.yaml

# Defaults
defaults:
  # _posts
  - scope:
      path: ""
      type: posts
    values:
      layout: single
      author_profile: false
      read_time: false
      comments: true
      share: true
      related: true
  # _pages
  - scope:
      path: ""
      type: pages
    values:
      layout: single
      author_profile: true
  # _portfolio
  - scope:
      path: ""
      type: posts
    values:
      layout: single
      author_profile: false
      read_time: false
      comments: true
      share: true
      related: true

site.posts is a thing - but unless you setup a collection called portfolio site.portfolio won’t work.

You could try doing them both as posts but using categories - you can use a folder named blog and have a _posts folder inside it, then they will all be category = blog, you could then have a folder named portfolio with a _posts folder inside it and then those would be category = portfolio. You could then filter site.posts to just get the ones that match a given category.

Or you could probably do them as collections, depends on if you are using any of the posts features which maybe the archive.html is.

I added this to my config and still no luck. This seems much easier than creating more folders with _posts folders in each.

collections:
  - portfolio

try doing it without the include and just see if you can get it to output the title to see if the collection is working.

Can you share a link to the repo?

That breaks it, and there is kinda some non-public stuff in the drafts so its a private repo atm.

         Rendering: _pages/portfolio.html
  Pre-Render Hooks: _pages/portfolio.html
  Rendering Liquid: _pages/portfolio.html
github-pages 227 | Error:  Liquid syntax error (line 5): Unknown tag 'archive'

I also tried the solution of _posts in separate folders.

It doesn’t work either, now nothing shows.

portfolio → _posts
blog → _posts

blog.html is now:

---
layout: archive
title: ""
permalink: /blog/
author_profile: false
---

{% include base_path %}

{% for post in site.blog if post.category == blog %}
  {% include archive.html %}
{% endfor %}

portfolio.html

---
layout: archive
title: ""
permalink: /portfolio/
author_profile: false
---

{% include base_path %}


{% for post in site.portfolio if post.category == portfolio %}
  {% include archive.html %}
{% endfor %}

I also tried for post in site.blog.posts and no luck

I am not so sure your if category is correct.

Need to do one step at a time - if you do it as posts just use the folder structure but don’t try to use the category yet - just see if you can get both pages to show all the posts. Then work on showing just one category.

If you do it as a collection, my comment was there may be something in the archive include that is only going to work on posts. I would not use it and would just output the title on your own.

I don’t think that is the correct syntax - did you see that somewhere? or are you just trying random things?

try
{% for post in site.categories.blog %}

I don’t know all the category ins and outs off the top of my head, a qucik google search for jekyll posts category got me a bunch of results like this that look good:

keep in mind there are different ways to do things - like the cat can be set via sub folder or front matter, that example uses front matter.

adding categories to the posts and using liquid to loop over each category worked!