Permalink
Browse files

--multiviews flag to not use .html in post links. For use with Apache…

… "Options +MultiViews".
1 parent 5f7bd00 commit 1d42b39f70415fc69f80e6736649bc570ff4e2cb @henrik committed Apr 23, 2009
Showing with 18 additions and 2 deletions.
  1. +9 −0 README.textile
  2. +5 −1 bin/jekyll
  3. +4 −1 lib/jekyll/post.rb
View
@@ -217,6 +217,15 @@ date parts and post name will be made and an index.html will be placed in the
leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
$ jekyll --permalink [date|none|pretty]
+
+Another way to leave off the .html is to configure Apache with 'Options +MultiViews'.
+Just link to pages without the extension (and without a trailing slash, like '/about').
+Then tell Jekyll not to add '.html' when linking to blog posts, like so:
+
+ $ jekyll --multiviews
+
+Note that this has no effect with '--permalink pretty' since that makes an index.html
+file in a directory.
h3. Permalink Date Format
View
@@ -55,7 +55,11 @@ opts = OptionParser.new do |opts|
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
options['permalink'] = style unless style.nil?
end
-
+
+ opts.on("--multiviews", "Don't use .html in links since Apache has 'Options +MultiViews'") do |style|
+ options['multiviews'] = true
+ end
+
opts.on("--permalink-date [FORMAT]", 'A strftime type format string. No times. (default format %Y/%m/%d)') do |format|
options['permalink_date'] = format unless format.nil?
end
View
@@ -123,7 +123,7 @@ def permalink
#
# Returns <String>
def url
- ext = self.site.permalink_style == :pretty ? '' : '.html'
+ ext = (site.permalink_style == :pretty || site.config['multiviews']) ? '' : '.html'
permalink || self.id + ext
end
@@ -214,6 +214,9 @@ def write(dest)
if self.site.permalink_style == :pretty
FileUtils.mkdir_p(path)
path = File.join(path, "index.html")
+ else
+ # Ensure .html extension even if URL doesn't have it, e.g. with --multiviews.
+ path.sub!(/(\.html)?$/, '.html')
end
File.open(path, 'w') do |f|

0 comments on commit 1d42b39

Please sign in to comment.