Added option to not put file date in permalink URL
This commit is contained in:
parent
eb70d75d44
commit
0b78c32771
|
@ -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
|
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
|
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory found in
|
||||||
subdirectories below the root.
|
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
|
URL) that the final HTML file should have. Open up the file corresponding to a
|
||||||
blog post:
|
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.
|
"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]
|
$ 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
|
h2. Data
|
||||||
|
|
||||||
Jekyll traverses your site looking for files to process. Any files with YAML
|
Jekyll traverses your site looking for files to process. Any files with YAML
|
||||||
|
|
|
@ -47,6 +47,11 @@ opts = OptionParser.new do |opts|
|
||||||
puts 'You must have the rdiscount gem installed first'
|
puts 'You must have the rdiscount gem installed first'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
||||||
|
Jekyll.permalink_style = (style || 'date').to_sym
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.parse!
|
opts.parse!
|
||||||
|
|
|
@ -46,12 +46,13 @@ module Jekyll
|
||||||
VERSION = '0.3.0'
|
VERSION = '0.3.0'
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
|
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc,:permalink_style
|
||||||
end
|
end
|
||||||
|
|
||||||
Jekyll.lsi = false
|
Jekyll.lsi = false
|
||||||
Jekyll.pygments = false
|
Jekyll.pygments = false
|
||||||
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
|
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
|
||||||
|
Jekyll.permalink_style = :date
|
||||||
|
|
||||||
def self.process(source, dest)
|
def self.process(source, dest)
|
||||||
require 'classifier' if Jekyll.lsi
|
require 'classifier' if Jekyll.lsi
|
||||||
|
|
|
@ -61,7 +61,7 @@ module Jekyll
|
||||||
# The generated directory into which the post will be placed
|
# The generated directory into which the post will be placed
|
||||||
# upon generation. This is derived from the permalink or, if
|
# upon generation. This is derived from the permalink or, if
|
||||||
# permalink is absent, set to the default date
|
# 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>
|
# Returns <String>
|
||||||
def dir
|
def dir
|
||||||
|
@ -69,7 +69,11 @@ module Jekyll
|
||||||
permalink.to_s.split("/")[0..-2].join("/")
|
permalink.to_s.split("/")[0..-2].join("/")
|
||||||
else
|
else
|
||||||
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
|
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
|
||||||
|
if Jekyll.permalink_style == :date
|
||||||
prefix + date.strftime("/%Y/%m/%d/")
|
prefix + date.strftime("/%Y/%m/%d/")
|
||||||
|
else
|
||||||
|
prefix + '/'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue