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

Generate a feed for each category. #176

Closed
wants to merge 2 commits into from

Conversation

mortenson
Copy link

Like others in #70, I want to have a feed per-category so that readers can subscribe only to topics that interest them. When testing this PR, you should be able to visit /feed/category.xml, where "category" is your category name.

I've only implemented categories here, as it seems like there would be loads of tags and users may expect complicated syntax like: /feed/tag1/tag2/combined.xml. Categories are how you categorize your content, so it makes sense that they would represent individual feeds.

I just started using Jekyll, and have never written Ruby/Liquid before, so forgive me if anything is amiss here.

@benbalter
Copy link
Contributor

@mortenson this great. Thanks for opening the PR.

I'd be curious your thoughts on #70 (comment) and the subsequent discussion. It sounds like you're moving from a platform that offers category feeds and are seeking to maintain feature parity. If we add a feature, we have to support it in perpetuity, regardless of how often it's used. Do you have any stats on how often category feeds are subscribed to?

@mortenson
Copy link
Author

I don't have much quantitative data - but can speak to why I would like to see this feature. As I mentioned earlier, I just started using Jekyll this week, and got a minimal blog up at http://mortenson.coffee/blog. This is my personal site, and I plan on writing posts about a variety of topics.

The problem I'm running into is that I'd like to add my blog to Planet Drupal, which is an aggregate of a ton of Drupal community blogs, but they specifically require that your RSS feed only contains Drupal-related content:

You must have an RSS feed that contains only content appropriate for Drupal Planet. If your site uses Drupal, you can create a "Drupal Planet" taxonomy term and use it to tag any content you want to appear on the Planet. Drupal automatically creates an RSS feed for each taxonomy term, and you can submit that term’s feed URL in your Drupal Planet application. Alternatively, you can use the Drupal Planet feature module, which uses Flag and Views modules to create the feed. If you are not using Drupal, you will need to make sure your site can create a feed just for your Planet content.
source

My blog at this point would not qualify for aggregation here, as I plan to mix personal posts with Drupal-related posts. There are 615 sites in this aggregate, and each site provides a specific RSS feed just for Drupal. It helps that most of those blogs are also built with Drupal, which provides this functionality out of the box and is highly utilized. A similar CMS, Wordpress, lets you filter arbitrarily by multiple criteria (author, tag, date, etc.), which obviously isn't a fit for static sites.

In the short-term, I could just create a hard-coded RSS page in Jekyll that only shows Drupal posts, but if I want to add my blog to a security aggregate I would have to do the same task. The same goes for displaying just my personal posts on another site - without this functionality I'll end up maintaining my own RSS feeds, which means I wouldn't be using jekyll-feed at all.

@RobbiNespu
Copy link

I often use category feeds are subscribed to Fedora planet which which is an aggregate feed of Fedora communities. I am using blogspot before, now after move to jekyll.. I need this features on my theme which using jekyll-feed plugin.

@marco-c
Copy link

marco-c commented Jul 28, 2017

Same on Planet Mozilla.

@halirutan
Copy link

Same for user feeds on specific StackExchange chats. Although my community is very open and wouldn't bother some off-topic posts, I would like to separate this too. Not that I have time to write many posts, but this is another issue.

@kylebarbour
Copy link
Contributor

kylebarbour commented Jan 17, 2018

I would benefit from this substantially as my site currently has several separate sections with significantly disparate content — few, if any of my subscribers use both. Migrating to Jekyll has meant that new posts are substantially easier, but a unified feed for everything on the site doesn't meet my needs. This particular feature seems to me to be a fairly minimal change and one worth supporting.

If the concern is that automatic generation of new feeds is unwanted — as that changes the default output — a simple solution would be to enable specific categories in your _config.yml. In other words, for someone with the categories xyzzy, plugh, and thud, the default would still be to generate a single unified feed.xml. However, with:

feed:
    multifeed:
      - xyzzy
      - plugh

in the user's _config.yml, the unified feed.xml would still be generated, as would the category-specific xyzzy.xml and plugh.xml feeds (but not thud, which was not specified).

I was actually about to start working on a PR that functioned that way before I found this, but thought I ought to mention that possibility before duplicating efforts.

Thoughts?

@benbalter
Copy link
Contributor

I think I was the one that originally 👎'd this feature. I still stand by my comments in #70 (comment), but it's clear that it's something many users want to implement (even if what little data we have suggests it's not actually used). If we can implement this in a way that minimizes complexity and the burden on the user, I'd be 👍 to supporting this going forward (and will leave some comments on the PR about the code itself).

@@ -33,6 +33,11 @@

{% assign posts = site.posts | where_exp: "post", "post.draft != true" %}
{% for post in posts limit: 10 %}
{% if page.category %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to filter the category above, otherwise the limit will be off. I believe the following should work:

site.categories[page.category] | where_exp: "post", "post.draft != true"

@site.pages << content_for_file(feed_path, feed_source_path)
end
@site.categories.each do |category|
path = "/feed/" + category.first + ".xml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is category.first?

file = PageWithoutAFile.new(@site, __dir__, "", file_path)
file.content = File.read(file_source_path).gsub(MINIFY_REGEX, "")
file.data["layout"] = nil
file.data["sitemap"] = false
file.data["xsl"] = file_exists?("feed.xslt.xml")
file.data["category"] = category
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be cleaner to allow the template to accept an arbitrary array of documents? That way, we can pass it all post, a category, a tag, or even another collection.

@halirutan
Copy link

@benbalter Thanks for pushing this PR forward. This is highly appreciated.

@halirutan
Copy link

@mortenson Any chance you can fix the issues pointed out by @benbalter? I'm still keen to see this merged. Or has a similar feature been added to Jekyll in the meantime by a different PR?

@mortenson
Copy link
Author

@halirutan I believe #228 is the PR to watch now - @benbalter is working on it.

@mortenson
Copy link
Author

#228 Has been merged, closing.

@mortenson mortenson closed this Sep 6, 2018
@jekyll jekyll locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants