Skip to content

Commit

Permalink
--multiviews flag to not use .html in post links. For use with Apache…
Browse files Browse the repository at this point in the history
… "Options +MultiViews".
  • Loading branch information
henrik committed Apr 23, 2009
1 parent 5f7bd00 commit 1d42b39
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion bin/jekyll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/jekyll/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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|
Expand Down

0 comments on commit 1d42b39

Please sign in to comment.