From 5878acaaf1a0e0883364143abde32447b4f2f771 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 22 Jan 2016 09:36:55 -0800 Subject: [PATCH] Document#post_read: only overwrite slug & ext if they aren't set by YAML --- lib/jekyll/document.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index c6f3cb87..2840ba51 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -290,18 +290,19 @@ module Jekyll def post_read if relative_path =~ DATE_FILENAME_MATCHER - _, date, slug, ext = $1, $2, $3, $4 + date, slug, ext = $2, $3, $4 if !data['date'] || data['date'].to_i == site.time.to_i merge_data!({"date" => date}, source: "filename") end elsif relative_path =~ DATELESS_FILENAME_MATCHER - _, slug, ext = $1, $2, $3 + slug, ext = $2, $3 end - merge_data!({"slug" => slug, "ext" => ext}, source: "filename") - # Try to ensure the user gets a title. data["title"] ||= Utils.titleize_slug(slug) + # Only overwrite slug & ext if they aren't specified. + data['slug'] ||= slug + data['ext'] ||= ext populate_categories populate_tags