Remove relative permalinks

This commit is contained in:
Alfred Xing 2015-04-28 14:03:20 -07:00
parent 786f6e1985
commit 9ab3c201c8
7 changed files with 15 additions and 49 deletions

View File

@ -36,16 +36,12 @@ module Jekyll
end end
def deprecated_relative_permalinks(site) def deprecated_relative_permalinks(site)
contains_deprecated_pages = false if site.config['relative_permalinks']
site.pages.each do |page| Jekyll::Deprecator.deprecation_message "Your site still uses relative" +
if page.uses_relative_permalinks " permalinks, which was removed in" +
Jekyll::Deprecator.deprecation_message "'#{page.path}' uses relative" + " Jekyll v3.0.0."
" permalinks which will be deprecated in" + return true
" Jekyll v2.0.0 and beyond."
contains_deprecated_pages = true
end
end end
contains_deprecated_pages
end end
def conflicting_urls(site) def conflicting_urls(site)

View File

@ -45,9 +45,6 @@ module Jekyll
'host' => '127.0.0.1', 'host' => '127.0.0.1',
'baseurl' => '', 'baseurl' => '',
# Backwards-compatibility options
'relative_permalinks' => false,
# Output Configuration # Output Configuration
'permalink' => 'date', 'permalink' => 'date',
'paginate_path' => '/page:num', 'paginate_path' => '/page:num',

View File

@ -52,11 +52,7 @@ module Jekyll
# Returns the String permalink or nil if none has been set. # Returns the String permalink or nil if none has been set.
def permalink def permalink
return nil if data.nil? || data['permalink'].nil? return nil if data.nil? || data['permalink'].nil?
if site.config['relative_permalinks'] data['permalink']
File.join(@dir, data['permalink'])
else
data['permalink']
end
end end
# The template of the permalink. # The template of the permalink.
@ -156,9 +152,5 @@ module Jekyll
def index? def index?
basename == 'index' basename == 'index'
end end
def uses_relative_permalinks
permalink && !@dir.empty? && site.config['relative_permalinks']
end
end end
end end

View File

@ -287,12 +287,12 @@ module Jekyll
# #
# Returns # Returns
def relative_permalinks_are_deprecated def relative_permalinks_are_deprecated
if config['relative_permalinks'] && has_relative_page? if config['relative_permalinks']
Jekyll::Deprecator.deprecation_message "Since v2.0, permalinks for pages" + Jekyll.logger.abort_with "Since v3.0, permalinks for pages" +
" in subfolders must be relative to the" + " in subfolders must be relative to the" +
" site source directory, not the parent" + " site source directory, not the parent" +
" directory. Check http://jekyllrb.com/docs/upgrading/"+ " directory. Check http://jekyllrb.com/docs/upgrading/"+
" for more info." " for more info."
end end
end end
@ -370,14 +370,6 @@ module Jekyll
private private
# Checks if the site has any pages containing relative links
#
# Returns a Boolean: true for usage of relateive permalinks, false
# if it doesn't
def has_relative_page?
pages.any? { |page| page.uses_relative_permalinks }
end
# Limits the current posts; removes the posts which exceed the limit_posts # Limits the current posts; removes the posts which exceed the limit_posts
# #
# Returns nothing # Returns nothing

View File

@ -1,6 +1,5 @@
markdown: kramdown markdown: kramdown
highlighter: pygments highlighter: pygments
relative_permalinks: false
permalink: /news/:year/:month/:day/:title/ permalink: /news/:year/:month/:day/:title/
excerpt_separator: "" excerpt_separator: ""

View File

@ -502,9 +502,6 @@ port: 4000
host: 127.0.0.1 host: 127.0.0.1
baseurl: "" # does not include hostname baseurl: "" # does not include hostname
# Backwards-compatibility
relative_permalinks: false
# Outputting # Outputting
permalink: date permalink: date
paginate_path: /page:num paginate_path: /page:num

View File

@ -42,19 +42,12 @@ your site.
In Jekyll v1.0, we introduced absolute permalinks for pages in In Jekyll v1.0, we introduced absolute permalinks for pages in
subdirectories. Starting with v2.0, absolute permalinks are opt-out, subdirectories. Starting with v2.0, absolute permalinks are opt-out,
meaning Jekyll will default to using absolute permalinks instead of meaning Jekyll will default to using absolute permalinks instead of
relative permalinks. relative permalinks. Relative permalink backwards-compatibility was removed in v3.0.
* To use absolute permalinks, set `relative_permalinks: false` in your
configuration file.
* To continue using relative permalinks, set `relative_permalinks: true` in
your configuration file.
<div class="note warning" id="absolute-permalinks-warning"> <div class="note warning" id="absolute-permalinks-warning">
<h5 markdown="1">Absolute permalinks will be default in v2.0 and on</h5> <h5 markdown="1">Absolute permalinks will be required in v3.0 and on</h5>
<p markdown="1"> <p markdown="1">
Starting with Jekyll v2.0, `relative_permalinks` will default to `false`, Starting with Jekyll v3.0, relative permalinks functionality will be removed and thus unavailable for use.
meaning all pages will be built using the absolute permalink behaviour.
The switch will still exist until v2.0.
</p> </p>
</div> </div>