Skip to content

Continue work on `write` command #1395

wants to merge 11 commits into from

8 participants

Jekyll member
parkr commented Aug 7, 2013

Looks like @Schoonology is no longer working on his PR (#1148) so I wanted to
continue work on this stuff here.

  • Implement command
  • Implement Template class (or something similar)
  • Write tests for Template class
  • Write integration features for writing


$ jekyll write post --title TITLE [--link LINK] [--layout LAYOUT] [--ext EXT]
# generates post at _posts/2013-08-07-title.EXT like this:
# ---
# layout: LAYOUT # (defaults to 'default', maybe?)
# date: "2013-08-07T23:14:13+02:00"
# title: TITLE
# [link: LINK]
# ---

$ jekyll write page --path PATH [--title TITLE] [--layout LAYOUT]
# generates page at PATH like this:
# ---
# layout: LAYOUT
# title: TITLE # if provided
# ---

$ jekyll write post --template post --title TITLE
# reads in contents of `_write/post.erb`, runs it through ERB and outputs it to the proper place
# it would also take all the options above and set each of them as variables,
#     thus `--layout LAYOUT` is accessible via `<%= layout # outputs "LAYOUT" %>`.

# Same thing with pages.
Schoonology and others added some commits May 24, 2013
@Schoonology Schoonology Implemented `write` command.
`jekyll write [type]` creates a new post, page, or draft depending on [type]. It supports option for --path, --title, and --ext.

See `jekyll help write`.
@Schoonology Schoonology fixup! Implemented `write` command. 0ee99f8
@parkr parkr Merge branch 'write_command' of git:// i…
…nto write-command

* 'write_command' of git://
  fixup! Implemented `write` command.
  Implemented `write` command.
@parkr parkr Default to 'draft' instead of 'post' d36e830
@parkr parkr Set path more generally in Write command. 665900a
@parkr parkr Use String#empty? instead of String=='' 7e7a789
@parkr parkr Fixes and tidying fe44d97
@parkr parkr Completely refactored into a new class. 4f2322e
@parkr parkr referenced this pull request Aug 7, 2013

Implemented `write` command. #1148


Wat. There's no way we want to be in the business of hard coding certain "blessed" YML attributes that you can pass via command line. That's a giant rabbit hole to start down.

What if the syntax was jekyll write [format] with two changes:

  1. Pass title immediately after format... assume I'm giving you a title... what's the downside if title is required?
  2. Any flag passed is converted to a YML key/value. so --layout post works, but --foo bar is just as supported.

Another idea:

What about supporting YML defaults like Prose does via _config.yml? Every time I write a post, there's ~10 YML fields I'll need to copy over (layout, comments, author, published, etc.). Would be awesome if we could just consume Prose's customizations or something similar so the command isn't 10 feet each time it's run.

mattvh commented Aug 8, 2013

@benbalter I like that idea.

On Jekyll Themes, I use a few "non-blessed" YAML keys like "demo" for the URL where a theme demo could be found and "thumbnail" for the associated image's filename. It's a little unwieldy if you're not just copying an old post manually.

Jekyll member
parkr commented Aug 8, 2013

@benbalter That's a good idea, but with Commander and OptionsParser in general, it's impossible to accept all options. For all unspecified options, one will receive a invalid option: --foo.

The two options which remain are (1) specify ERB files to read in, parse, and write, or (2) keep all the yaml you want in your posts in your config.yml. The latter sucks so the former is probably the best way to go.

scribu commented Sep 8, 2013

Since this also involves drafts, related discussion: #1469

Jekyll member
parkr commented Mar 16, 2014

Do we still think this is good to have bundled with Jekyll itself or have other tools filled the void satisfactorily?


I think that it's a good idea to have something standardised like this either in Jekyll core (preferable in my opinion) or available easily as a plugin. Is there anything available that isn't just people instrumenting around jekyll? I used to have a rake task that did something similar for instance.

@parkr parkr closed this Mar 17, 2014
@parkr parkr reopened this Mar 17, 2014
@parkr parkr modified the milestone: 2.1, 2.0 Apr 3, 2014
Jekyll member
parkr commented May 10, 2014

Going to take care of all of this in

@parkr parkr closed this May 10, 2014
@parkr parkr deleted the write-command branch May 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.