Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support categories/tags on posts #131

Closed
johannhof opened this issue Aug 20, 2016 · 10 comments
Closed

Support categories/tags on posts #131

johannhof opened this issue Aug 20, 2016 · 10 comments
Assignees
Labels
enhancement Improve the expected
Milestone

Comments

@johannhof
Copy link
Contributor

Would be nice to be able to define a number of categories in front matter that would then be available as e.g. a Liquid object for rendering.

@johannhof johannhof added the enhancement Improve the expected label Aug 20, 2016
@johannhof johannhof self-assigned this Jan 16, 2017
@johannhof johannhof added this to the 0.6 milestone Jan 16, 2017
@uwearzt
Copy link
Contributor

uwearzt commented Feb 10, 2017

I started to work on this.

@johannhof johannhof removed their assignment Feb 10, 2017
@ducks
Copy link
Contributor

ducks commented Feb 24, 2017

Howdy @uwearzt. I was curious if you had made any progress on this. I was thinking of poking at it a bit but don't want to step on your toes if you're close to a PR or anything.

@uwearzt
Copy link
Contributor

uwearzt commented Feb 25, 2017

Hi, I am making slow progress ;), too much work to do. I will push the intermediate progress on Monday or Tuesday. Then we can work together...

@uwearzt
Copy link
Contributor

uwearzt commented Feb 28, 2017

See #196 for a first take. I am especially interested in reviewing the categories.liquid file and if it is OK to add preserve_order to rust-yaml.

@uwearzt uwearzt self-assigned this Jun 25, 2017
@epage
Copy link
Member

epage commented Jul 5, 2017

@uwearzt, could you describe how you imagine categories working?

@uwearzt
Copy link
Contributor

uwearzt commented Jul 7, 2017

@epage

  1. Add Categories to your posts (the categories are also used for jsonfeed)
categories: [CatE, SubCatC]
  1. Add Categories to the cobalt.yml file
categories: [ CatA : [],
              CatB : [ SubCatC, SubCatD ],
              CatE : [ SubCatF ]]

there will be (at least) a info message if you use a category inside a post which is not defined here.

  1. Use them for a Tree with posts:
<div>
  <h3>print categories with posts</h3>
    <!-- check if there are categories in config -->
    {%if site.categories %}
      <!-- run over categories -->
      {% for category in site.categories %}
        <h4>{{ category.name }}</h4>
        <!-- run over posts -->
        {% if category.posts %}
          Posts in this category<br/>
          {% for post in category.posts %}
            {{ post.date | date: "%d.%m.%Y" }} | {{ post.title }}<br/>
          {% endfor %}
        {% endif %}
        <!-- run over subcategories -->
        {% if category.subcategories %}
          {% for subcategory in category.subcategories %}
            <h5>{{ subcategory.name }}</h5>
            <!-- run over posts -->
            {% if subcategory.posts %}
              Posts in this subcategory<br/>
              {% for post in subcategory.posts %}
                {{ post.date | date: "%d.%m.%Y" }} | {{ post.title }}<br/>
              {% endfor %}
            {% endif %}
          {% endfor %}
        {% endif %}
      {% endfor %}
    {% endif %}
</div>

@epage
Copy link
Member

epage commented Jul 7, 2017

So defining categories in cobalt.yml is meant to

  1. Perform validity checking on frontmatter categories
  2. Simplify creation of category attributes for or use in some kind of index page

One of my concerns is creating the tree of posts for all pages, causing lots of memory bloat / copies. I have an idea for improving this in liquid (supporting overlaying liquid::Objects

I'm also interested in learning more about hugo's _index.md.

btw my PR I'm preparing will allow using :categories in the frontmatter path.

@epage
Copy link
Member

epage commented Jul 12, 2017

#257 has added support for :categories when generating an output path.

@epage
Copy link
Member

epage commented Jan 6, 2018

#354 is tracking work on doing something like Hugo's _index.md

@epage epage modified the milestones: 0.6, 1.0 Jan 7, 2018
@Geobert Geobert mentioned this issue Mar 11, 2018
12 tasks
@epage
Copy link
Member

epage commented Jan 14, 2022

I think between our pagination work and the other issues, this is resolved.

@epage epage closed this as completed Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

4 participants