Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/athackst/jekyll-collection-pages
Add collection index pages based on front matter wit hand without pagination
https://github.com/athackst/jekyll-collection-pages
jekyll jekyll-plugin
Last synced: 4 days ago
JSON representation
Add collection index pages based on front matter wit hand without pagination
- Host: GitHub
- URL: https://github.com/athackst/jekyll-collection-pages
- Owner: athackst
- License: mit
- Created: 2024-08-01T06:57:04.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-03T04:02:00.000Z (3 months ago)
- Last Synced: 2024-10-30T21:38:49.623Z (6 days ago)
- Topics: jekyll, jekyll-plugin
- Language: Ruby
- Homepage: https://althack.dev/jekyll-collection-pages
- Size: 1.15 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
title: "Quick start"
category: "Getting Started"
order: 1
---## Usage
### Installation
Add this line to your Jekyll site's `Gemfile`:
```ruby
gem 'jekyll-collection-pages'
```And add this line to your Jekyll site's `_config.yml`:
```yaml
plugins:
- jekyll-collection-pages
```### Basic Configuration
In your `_config.yml`, add the following configuration for each collection you want to generate pages for:
```yaml
collection_pages:
- collection: docs
field: category
path: docs/category
layout: category_layout.html
paginate: 6
- collection: articles
field: tags
path: articles/tags
layout: tags_layout.html
paginate: 10
```### Configuration Options
- `collection`: The name of the collection to generate pages for.
- `field`: The front matter field to use for categorization (e.g., 'category', 'tags').
- `path`: The output path for the generated pages.
- `layout`: The layout to use for the generated pages.
- `paginate`: (Optional) The number of items per page. If omitted, all items will be on a single page.### Example Usage
1. **Setting up collections**
In your `_config.yml`:
```yaml
collections:
docs:
output: true
collection_pages:
collection: docs
field: category
path: docs/category
layout: category_layout.html
paginate: 6
```2. **Creating collection items**
Create files in your collections with appropriate front matter:
`_docs/sample-doc.md`:
```yaml
---
title: "Sample Document"
category: "User Guide"
---
This is a sample document.
````_articles/sample-article.md`:
```yaml
---
title: "Sample Article"
tags: ["Jekyll", "Plugins"]
---
This is a sample article.
```3. **Creating layouts**
Create layout files for your generated pages:
`_layouts/category_layout.html`:
```html
---
layout: default
---
Category: {{ page.tag }}
- {{ post.title }}
{% for post in page.posts %}
{% endfor %}
```
4. **Accessing generated pages**
The plugin will generate pages at paths like:
- `/docs/category/user-guide.html`
- `/articles/tags/jekyll.html`
- `/articles/tags/plugins.html`
### Pagination
If you've set the `paginate` option, you can access pagination information in your layouts:
```html
{% if paginator.total_pages > 1 %}
{% if paginator.previous_page %}
Previous
{% endif %}
Page {{ paginator.page }} of {{ paginator.total_pages }}
{% if paginator.next_page %}
Next
{% endif %}
{% endif %}
```
### Demo Site
For more complex examples and a full working demo, check out the [demo site](https://www.althack.dev/jekyll-collection-pages) included in this repository.