diff --git a/README.textile b/README.textile
index 4fa4c4061dc..a524ab4d9cb 100644
--- a/README.textile
+++ b/README.textile
@@ -34,7 +34,7 @@ fields such as title
and date
.
Jekyll gets the list of blog posts by parsing the files in any
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory found in
subdirectories below the root.
-Each post's filename contains the publishing date and slug (what shows up in the
+Each post's filename contains (by default) the publishing date and slug (what shows up in the
URL) that the final HTML file should have. Open up the file corresponding to a
blog post:
"2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
@@ -145,6 +145,17 @@ Default port is 4000:
$ jekyll --server [PORT]
+By default, the permalink for each post begins with its date in 'YYYY/MM/DD'
+format. If you do not wish to have the date appear in the URL of each post,
+you can change the permalink style to 'none' so that only the 'slug' part of
+the filename is used. For example, with the permalink style set to 'none' the
+file '2009-01-01-happy-new-year.markdown' will have a permalink like
+'http://yoursite.com/happy-new-year.html'. The date of the post will still be
+read from the filename (and is required!) to be used elsewhere in Jekyll.
+Example usage:
+
+ $ jekyll --permalink none
+
h2. Data
Jekyll traverses your site looking for files to process. Any files with YAML
diff --git a/bin/jekyll b/bin/jekyll
index d746806f7f9..9ed9b90b8f2 100755
--- a/bin/jekyll
+++ b/bin/jekyll
@@ -47,6 +47,11 @@ opts = OptionParser.new do |opts|
puts 'You must have the rdiscount gem installed first'
end
end
+
+ opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
+ Jekyll.permalink_style = (style || 'date').to_sym
+ end
+
end
opts.parse!
diff --git a/lib/jekyll.rb b/lib/jekyll.rb
index 829d1d4bde0..4a2e269ac86 100644
--- a/lib/jekyll.rb
+++ b/lib/jekyll.rb
@@ -46,12 +46,13 @@ module Jekyll
VERSION = '0.3.0'
class << self
- attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
+ attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc,:permalink_style
end
Jekyll.lsi = false
Jekyll.pygments = false
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
+ Jekyll.permalink_style = :date
def self.process(source, dest)
require 'classifier' if Jekyll.lsi
diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb
index 890cae8d4d8..8ee5a467ed4 100644
--- a/lib/jekyll/post.rb
+++ b/lib/jekyll/post.rb
@@ -61,7 +61,7 @@ def process(name)
# The generated directory into which the post will be placed
# upon generation. This is derived from the permalink or, if
# permalink is absent, set to the default date
- # e.g. "/2008/11/05/"
+ # e.g. "/2008/11/05/" if the permalink style is :date, otherwise nothing
#
# Returns
def dir
@@ -69,7 +69,11 @@ def dir
permalink.to_s.split("/")[0..-2].join("/")
else
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
- prefix + date.strftime("/%Y/%m/%d/")
+ if Jekyll.permalink_style == :date
+ prefix + date.strftime("/%Y/%m/%d/")
+ else
+ prefix + '/'
+ end
end
end