Skip to content

Commit

Permalink
Added option to not put file date in permalink URL
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid committed Jan 19, 2009
1 parent eb70d75 commit 0b78c32
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
13 changes: 12 additions & 1 deletion README.textile
Expand Up @@ -34,7 +34,7 @@ fields such as <code>title</code> and <code>date</code>.
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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions bin/jekyll
Expand Up @@ -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!
Expand Down
3 changes: 2 additions & 1 deletion lib/jekyll.rb
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions lib/jekyll/post.rb
Expand Up @@ -61,15 +61,19 @@ 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 <String>
def dir
if permalink
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

Expand Down

0 comments on commit 0b78c32

Please sign in to comment.