Skip to content
This repository

Do/Don't publish future-dated posts using jekyll's built-in support #837

Closed
wants to merge 1 commit into from

5 participants

J. B. Rainsberger Jeremy Zawodny Sergio Tulentsev Parker Moore Brandon Mathis
J. B. Rainsberger

I've added a configuration variable, and discovered that jekyll already supported this with a switch, which made it much easier.

J. B. Rainsberger We can now choose whether future-dated posts are published by default…
… with a configuration variable. We still see all posts in preview mode.
4b9b499
J. B. Rainsberger

Since jekyll already has a --no-future option, why don't we use it?

Jeremy Zawodny

+1

Parker Moore
Collaborator

Talked with @imathis and we both agree that this is not something we'd like to see in Octopress. Heck, we think it's a silly feature to have in Jekyll at all, but alas, it is there. We're going to stick with the use of published: false in the YAML Front-Matter of a post or page if one wishes not to publish it. Thanks for the suggestion, though!

Parker Moore parkr closed this December 27, 2012
J. B. Rainsberger

OK. I'm curious why you find it silly, in general.

Brandon Mathis
Owner

@jbrains I'll try to explain it a bit better. Why would someone use this? The only reason I can think of is that someone is trying to preview generated a post, but they don't want to publish it yet. So passing a flag to jekyll seems nicer than toggling a published variable.

While it might be simpler, I would argue this makes more sense in a dynamic blogging platform like Wordpress, where setting a future dated post means Wordpress will automatically publish it for you when that date arrives. In the case of Jekyll, you'll still have to generate and publish your blog when that date arrives. In that sense I don't see much value in setting future dated posts as a way to prevent them from being published.

I do however see potential problems where posts can be accidentally published because a blogger generated and deployed, forgetting they had a another post scheduled for that day. Since Jekyll doesn't have a GUI or a way to show upcoming posts, it would be easy to accidentally do something like this.

I feel like it would be much better to use Git branches for draft management. Create a branch, generate your blog without having to worry about post dates or Jekyll flags, and when you're ready to publish, merge the branch, generate and deploy. When we finish the CLI we may set it up to pass options and flags through to Jekyll which would make it so you can use this, but for now I think it's a bad way to manage drafts and I'm not interested in adding it to the Rakefile.

J. B. Rainsberger
Brandon Mathis imathis referenced this pull request from a commit January 13, 2013
Brandon Mathis Improved draft management options
- rake list_drafts shows current drafts. Closes #645
- Rake generate, watch, and preview can compile future dated posts (defaults to false). Closes #837
38353f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 03, 2012
J. B. Rainsberger We can now choose whether future-dated posts are published by default…
… with a configuration variable. We still see all posts in preview mode.
4b9b499
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 16 additions and 2 deletions. Show diff stats Hide diff stats

  1. 17  Rakefile
  2. 1  _config.yml
17  Rakefile
@@ -47,20 +47,32 @@ end
47 47
 # Working with Jekyll #
48 48
 #######################
49 49
 
  50
+publish_future_dated_posts_switch = "" # backwards-compatible default value
  51
+
  52
+desc "Read Jekyll configuration"
  53
+task :read_jekyll_configuration do
  54
+  jekyll_configuration = YAML.load_file("./_config.yml")
  55
+
  56
+  # As of this writing, jekyll's default option is --future
  57
+  publish_future_dated_posts_option = jekyll_configuration.has_key?("publish_future_dated_posts") ? jekyll_configuration["publish_future_dated_posts"] : true
  58
+  publish_future_dated_posts_switch = publish_future_dated_posts_option ? "--future" : "--no-future"
  59
+end
  60
+
50 61
 desc "Generate jekyll site"
51 62
 task :generate do
52 63
   raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
53 64
   puts "## Generating Site with Jekyll"
54 65
   system "compass compile --css-dir #{source_dir}/stylesheets"
55  
-  system "jekyll"
  66
+  system "jekyll #{publish_future_dated_posts_switch}"
56 67
 end
  68
+task :generate => :read_jekyll_configuration
57 69
 
58 70
 desc "Watch the site and regenerate when it changes"
59 71
 task :watch do
60 72
   raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
61 73
   puts "Starting to watch source with Jekyll and Compass."
62 74
   system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css")
63  
-  jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto")
  75
+  jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll --auto #{publish_future_dated_posts_switch}")
64 76
   compassPid = Process.spawn("compass watch")
65 77
 
66 78
   trap("INT") {
@@ -70,6 +82,7 @@ task :watch do
70 82
 
71 83
   [jekyllPid, compassPid].each { |pid| Process.wait(pid) }
72 84
 end
  85
+task :watch => :read_jekyll_configuration
73 86
 
74 87
 desc "preview the site in a web browser"
75 88
 task :preview do
1  _config.yml
@@ -42,6 +42,7 @@ recent_posts: 5       # Posts in the sidebar Recent Posts section
42 42
 excerpt_link: "Read on →"  # "Continue reading" link text at the bottom of excerpted articles
43 43
 
44 44
 titlecase: true       # Converts page and post titles to titlecase
  45
+publish_future_dated_posts: false
45 46
 
46 47
 # list each of the sidebar modules you want to include, in the order you want them to appear.
47 48
 # To add custom asides, create files in /source/_includes/custom/asides/ and add them to the list like 'custom/asides/custom_aside_name.html'
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.