From 0c624eb11bc879a1df262290842f936ee7f36e71 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 30 Jan 2015 01:53:11 -0800 Subject: [PATCH] The :title URL placeholder for collections should be the filename slug. This mimicks posts most closely. It can be overridden by the YAML front matter. Undoes some of #2864. --- lib/jekyll/document.rb | 2 +- site/_docs/permalinks.md | 5 ++++- test/source/_slides/example-slide-4.html | 2 +- test/source/_slides/example-slide-6.html | 15 +++++++++++++++ test/test_document.rb | 13 +++++++++---- 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 test/source/_slides/example-slide-6.html diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index ec9ee742..048dcdbf 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -132,7 +132,7 @@ module Jekyll path: cleaned_relative_path, output_ext: Jekyll::Renderer.new(site, self).output_ext, name: Utils.slugify(basename_without_ext), - title: Utils.slugify(data['title']) || Utils.slugify(basename_without_ext) + title: Utils.slugify(data['slug']) || Utils.slugify(basename_without_ext) } end diff --git a/site/_docs/permalinks.md b/site/_docs/permalinks.md index 703a2289..bf7e9481 100644 --- a/site/_docs/permalinks.md +++ b/site/_docs/permalinks.md @@ -78,7 +78,10 @@ permalink is defined as `/:categories/:year/:month/:day/:title.html`.

title

-

Title from the Post’s filename

+

+ Title from the document’s filename. May be overridden via the + document’s slug YAML front matter. +

diff --git a/test/source/_slides/example-slide-4.html b/test/source/_slides/example-slide-4.html index 6cec4eae..b4bdbe45 100644 --- a/test/source/_slides/example-slide-4.html +++ b/test/source/_slides/example-slide-4.html @@ -1,5 +1,5 @@ --- - title: So what is Jekyll, exactly? + slug: so-what-is-jekyll-exactly layout: slide --- diff --git a/test/source/_slides/example-slide-6.html b/test/source/_slides/example-slide-6.html new file mode 100644 index 00000000..defbb52d --- /dev/null +++ b/test/source/_slides/example-slide-6.html @@ -0,0 +1,15 @@ +--- + slug: Well, so what is Jekyll, then? + layout: slide +--- + +Jekyll is a simple, blog-aware, static site generator. It takes a template +directory containing raw text files in various formats, runs it through +[Markdown](http://daringfireball.net/projects/markdown/) (or +[Textile](http://redcloth.org/textile)) and +[Liquid](http://wiki.shopify.com/Liquid) +converters, and spits out a complete, ready-to-publish static website suitable +for serving with your favorite web server. Jekyll also happens to be the engine +behind [GitHub Pages](http://pages.github.com), which means you can use Jekyll +to host your project’s page, blog, or website from GitHub’s servers **for +free**. diff --git a/test/test_document.rb b/test/test_document.rb index f8243aa1..aa4e2fa9 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -249,15 +249,20 @@ class TestDocument < Test::Unit::TestCase })) @site.process @document = @site.collections["slides"].docs[3] - @document_without_title = @site.collections["slides"].docs[4] + @document_without_slug = @site.collections["slides"].docs[4] + @document_with_strange_slug = @site.collections["slides"].docs[5] end - should "produce the right URL if they have a title" do + should "produce the right URL if they have a slug" do assert_equal "/slides/so-what-is-jekyll-exactly", @document.url end - should "produce the right URL if they don't have a title" do - assert_equal "/slides/example-slide-5", @document_without_title.url + should "produce the right URL if they don't have a slug" do + assert_equal "/slides/example-slide-5", @document_without_slug.url + end + + should "produce the right URL if they have a wild slug" do + assert_equal "/slides/well-so-what-is-jekyll-then", @document_with_strange_slug.url end end