diff --git a/docs/_docs/upgrading/3-to-4.md b/docs/_docs/upgrading/3-to-4.md
index f483e64aa1d..fe3f40b5435 100644
--- a/docs/_docs/upgrading/3-to-4.md
+++ b/docs/_docs/upgrading/3-to-4.md
@@ -22,6 +22,25 @@ and fetch the latest version of Jekyll:
gem update jekyll
```
+
+
post_url
Tag and Baseurl
+
+
+ The post_url
tag now incorporates the relative_url
filter within itself
+ and therefore automatically prepends your site's baseurl
to the post's url
+ value.
+
+
+ Please ensure that you change all instances of the post_url
usage as following:
+
+
+{% highlight diff %}
+- {{ site.baseurl }}/{% post_url 2018-03-20-hello-world.markdown %}
++ {% post_url 2018-03-20-hello-world.markdown %}
+{% endhighlight %}
+
+
+
## Template rendering
We've slightly altered the way Jekyll parses and renders your various templates
diff --git a/docs/_sass/_style.scss b/docs/_sass/_style.scss
index 4b58e33ff4c..deafe505f50 100644
--- a/docs/_sass/_style.scss
+++ b/docs/_sass/_style.scss
@@ -708,6 +708,15 @@ h5 > code,
0 -1px 0 rgba(0,0,0,.5));
}
+.note .highlight {
+ width: 94%;
+ pre code {
+ font-size: 0.9em;
+ background-color: transparent;
+ box-shadow: none;
+ }
+}
+
.note code {
background-color: #333;
background-color: rgba(0,0,0,0.2);
diff --git a/features/post_url_tag.feature b/features/post_url_tag.feature
index 0a764295fd0..172f914db15 100644
--- a/features/post_url_tag.feature
+++ b/features/post_url_tag.feature
@@ -71,7 +71,7 @@ Feature: PostUrl Tag
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
- And I should see "Welcome
" in "_site/index.html"
+ And I should see "Welcome
" in "_site/index.html"
Scenario: Posts with categories
Given I have a _posts directory
diff --git a/jekyll.gemspec b/jekyll.gemspec
index 801d764e8ee..2db9b7b836c 100644
--- a/jekyll.gemspec
+++ b/jekyll.gemspec
@@ -56,6 +56,10 @@ Gem::Specification.new do |s|
You should no longer prepend `{{ site.baseurl }}` to `{% link foo.md %}`
For further details: https://github.com/jekyll/jekyll/pull/6727
+ * Our `post_url` tag now comes with the `relative_url` filter incorporated into it.
+ You shouldn't prepend `{{ site.baseurl }}` to `{% post_url 2019-03-27-hello %}`
+ For further details: https://github.com/jekyll/jekyll/pull/7589
+
* Our `highlight` tag no longer parses Liquid and Liquid-like constructs in the
tag's content body. While this means you no longer need to enclose the content
within a `{% raw %}{% endraw %}` block, it also means that you can no longer
diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb
index 388124700e8..e6feb928e56 100644
--- a/lib/jekyll/tags/post_url.rb
+++ b/lib/jekyll/tags/post_url.rb
@@ -57,6 +57,8 @@ def post_slug(other)
end
class PostUrl < Liquid::Tag
+ include Jekyll::Filters::URLFilters
+
def initialize(tag_name, post, tokens)
super
@orig_post = post.strip
@@ -72,24 +74,25 @@ def initialize(tag_name, post, tokens)
end
def render(context)
+ @context = context
site = context.registers[:site]
- site.posts.docs.each do |p|
- return p.url if @post == p
+ site.posts.docs.each do |document|
+ return relative_url(document) if @post == document
end
# New matching method did not match, fall back to old method
# with deprecation warning if this matches
- site.posts.docs.each do |p|
- next unless @post.deprecated_equality p
+ site.posts.docs.each do |document|
+ next unless @post.deprecated_equality document
Jekyll::Deprecator.deprecation_message "A call to "\
"'{% post_url #{@post.name} %}' did not match " \
"a post using the new matching method of checking name " \
"(path-date-slug) equality. Please make sure that you " \
"change this tag to match the post's name exactly."
- return p.url
+ return relative_url(document)
end
raise Jekyll::Errors::PostURLError, <<~MSG