Skip to content


Allow options.sources to contain the same date component multiple times #112

merged 1 commit into from

3 participants


I organize my blog posts into folders by year, like so:

├── 2008
│   └──
├── 2009
│   └──
├── 2010
│   └──
├── 2011
│   └──
└── 2012

In configuring middleman-blogs sources option, I expected support for file name globbing, but was unable to use the expected globing pattern:

blog.sources = "posts/*/:year-:month-:day-:title"

Adding globbing support seemed like it might be a fair bit of work based on the ways the sources option is used in the code, so I opted to add the ability to use date keywords multiple times in the sources option, like so:

blog.sources = "posts/:year/:year-:month-:day-:title"

@tdreyno tdreyno merged commit ad67955 into middleman:master

1 check failed

Details default The Travis build failed
Middleman member

Nice! Thanks

@johndbritton johndbritton deleted the unknown repository branch
Middleman member

Awesome. I like being explicit about the date components better than the globs, anyway.


I would really like to have glob support, or the ability to add multiple source directories. Another thing I tried was this:

blog.sources = []
(2009..2013).each do |year|
  blog.sources << "/posts/#{year}/:year-:month-:day-:title"

If I organize posts by category, there's no easy way to add the different directories as sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/middleman-blog/blog_data.rb
6 lib/middleman-blog/blog_data.rb
@@ -29,9 +29,9 @@ def initialize(app, options={}, controller=nil)
matcher = Regexp.escape(options.sources).
sub(/^\//, "").
- sub(":year", "(\\d{4})").
- sub(":month", "(\\d{2})").
- sub(":day", "(\\d{2})").
+ gsub(":year", "(\\d{4})").
+ gsub(":month", "(\\d{2})").
+ gsub(":day", "(\\d{2})").
sub(":title", "([^/]+)")
subdir_matcher = matcher.sub(/\\\.[^.]+$/, "(/.*)$")
Something went wrong with that request. Please try again.