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

Exclude Drafts from feed #94

Closed
jeremiemartinez opened this issue Feb 8, 2016 · 15 comments
Closed

Exclude Drafts from feed #94

jeremiemartinez opened this issue Feb 8, 2016 · 15 comments

Comments

@jeremiemartinez
Copy link

Hi there,

What do you think about filtering future posts from the feed.xml ?

To give you some context, most of the time I write a new article, I publish it with a future date, it is not listed and I send direct link to friends for proof reading. My problem is that even if my article has a future date, it still appears in the feed.xml...

Would you be willing to accept a PR if I work on it ? Is there any other way to filter posts appearing in the feed.xml ?

Thanks,

@pathawks
Copy link
Member

pathawks commented Feb 9, 2016

I have also published a post “publically” for the purpose of sending it to somebody to proofread.

I’m not sure if future date is the way to do this, seems like that could lead to some trouble if time zones or something caused Jekyll to improperly exclude a new post from the feed.

Perhaps a way to explicitly exclude a post from the feed, similar to sitemap: false?

@jeremiemartinez
Copy link
Author

So we could have something like: feed: false that could be added to the frontmatter of each post and then filtered in the for loop in feed.xml. Is that what you mean ? It would also be a good solution since I understand your concerns about time zones.

@pathawks
Copy link
Member

pathawks commented Feb 9, 2016

So we could have something like: feed: false that could be added to the frontmatter of each post and then filtered in the for loop in feed.xml. Is that what you mean ?

👍

@benbalter
Copy link
Contributor

@jeremiemartinez how do you prevent future posts from appearing in your site's human-readable index?

I'm wondering if rather than have the user specify the feature they want ("don't include this in the sitemap", "don't include this in the feed"), the user should expose intend ("this shouldn't be public"), and the two plugins should respond accordingly.

@jeremiemartinez
Copy link
Author

@benbalter Well, my approach is very similar that the one advised by @pathawks. However, don't judge me, this is not the best code I wrote...

First, I add future: true to my _config.yml.
Then, I declare in the frontmatter of my post: public: 1
Finally, in my index.html, I loop and filter:

{% for post in paginator.posts %}
   {% if post.public != 1  %}
        […]
   {% endif %}
 {% endfor %}

Your idea about a public flag that could be used for every plugin is great but it would require to directly modify jekyll to expose such an API I guess :/

@pathawks
Copy link
Member

pathawks commented Feb 9, 2016

Jekyll has a Drafts feature already: is there any way in Liquid to detect if a post is a draft?

I can think of multiple reasons why a public page/post should be excluded from a sitemap (even if not excluded from the public view of a site), but the only reason I can think of to exclude a post from the site feed is if it is just a draft snd not yet “public.”

I am just trying to think through this aloud.

@jeremiemartinez
Copy link
Author

Draft would be a good solution but it seems that Github does not deploy drafts so I cannot ask friends for proofreading unfortunately.

@jeremiemartinez
Copy link
Author

Sorry I am completely wrong with my last comment. Just need to add show_drafts flag to my _config.yml. So knowing if a post is a draft matches our need.

@pathawks
Copy link
Member

pathawks commented Feb 9, 2016

I wasn’t thinking about GitHub Pages. That makes things a bit trickier, doesn’t it.

@jeremiemartinez
Copy link
Author

Well, as I corrected in my previous comment, with show_drafts Github Pages does work.

I looked for a way to know whether a post is a draft or not. We can with something like:

{% if post.draft == false %}

Or

{% unless post.draft %}

What do you think about this solution?

@pathawks pathawks changed the title Filtering future posts Exclude Drafts from feed Feb 9, 2016
@KingScooty
Copy link

{% for post in site.posts %}
    {% unless post.draft %}
    {% endunless %}
{% endfor %}

@jeremiemartinez
Copy link
Author

Fixed by #95.

@jeremiemartinez
Copy link
Author

Hey guys, any idea about a release date ? I would love to include this change in my current project!

@parkr
Copy link
Member

parkr commented Apr 14, 2016

@jeremiemartinez v0.5.0 was just released. 😄

@jeremiemartinez
Copy link
Author

Great news ! Thanks :)

meribold added a commit to meribold/meribold.org that referenced this issue Feb 8, 2018
* Use the jekyll-feed gem [1] to generate an Atom [2] feed.  Drafts are
  automatically excluded from the feed [3].
* Add the `show_drafts` flag to my `_config.yml`, so drafts are rendered
  on GitHub Pages (see [4]).
* Move `_posts/2017-09-02-meta.md` to `_drafts/meta.md`, so it's
  excluded from the feed.
* Modify `home.html` so drafts aren't shown in the index of posts.
* Add a new page which is an index of all drafts.
* Link to the feed from the footer (instead of linking to my GitHub
  profile).

(I want drafts to be available on GitHub Pages, so I can check how they
look on my phone or send links to friends for proofreading.)

[1]: https://github.com/jekyll/jekyll-feed
[2]: https://en.wikipedia.org/wiki/Atom_(Web_standard)
[3]: jekyll/jekyll-feed#94
[4]: jekyll/jekyll-feed#94 (comment)
ebekker added a commit to ebekker/ebekker.github.io that referenced this issue Jan 8, 2019
Keeping consistent with [jekyll-feed plugin's support](jekyll/jekyll-feed#94).
@jekyll jekyll locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants