Stefan_EOX
Stefan_EOX

Reputation: 1529

Exclude Jekyll posts from output (don't output individual HTML files)

Since I list all my posts in one page called fotos.html I don't need the individual posts to appear as HTML files in the _site output directory. How can I tell Jekyll to not output the .md posts in the _posts directory as individual HTML files?

[Screenshot of the Jekyll output directory

E.g. The contents of Firmwochenende.html are present in fotos.html with properly formatted title and date. Firmwochenende.html includes only photos and nothing else, which is not useful at all.

I build using build exec jekyll serve and host on Github Pages: https://github.com/junge-pfarre/junge-pfarre.github.io

These are the relevant parts of _config.yml:

defaults:
  - scope:
      path: ""
    values:
      layout: "default"
  - scope:
      path: "assets/flyer"
    values:
      flyer: true

markdown: kramdown

permalink: :title

A simple post has these contents:

---
title: Jugendandacht Gründonnerstag
---
![Altar der Josefskapelle in der Pfarrkirche Baden St. Stephan][1]

[1]: {{ site.baseurl }}{% link /assets/fotos/Jugendandacht2018.jpg %}

Upvotes: 0

Views: 1040

Answers (1)

Max Gardner
Max Gardner

Reputation: 301

You'll need to use a custom collection rather than the default as the _posts collection is, by design, always going to output individual files. If you create a new collection, you can specify output: false for that collection in your config file while still being able to iterate through it and display the content. From the Jekyll documentation:

# Config file

collections:
  your_collection_name:
    output: false

However, I saw that you mentioned pagination in the comments. I don't believe GitHub currently supports a gem that has pagination functionality for collections other than _posts (like jekyll-paginate-v2, though they're in talks on merging this in eventually). In the meantime, it looks like there are some solutions out there to help with this limitation.

Upvotes: 1

Related Questions