Replace '/index.html' with '/'

This commit is contained in:
Pat Hawks 2016-01-05 15:52:40 -08:00
parent 9f3da7e6fe
commit 23e9b8ae21
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
2 changed files with 13 additions and 4 deletions

View File

@ -41,8 +41,8 @@
{% endif %}
{% if seo_url %}
<link rel="canonical" href="{{ seo_url }}{{ page.url }}" itemprop="url" />
<meta property='og:url' content='{{ seo_url }}{{ page.url }}' />
<link rel="canonical" href="{{ seo_url }}{{ page.url | replace:'/index.html','/' }}" itemprop="url" />
<meta property='og:url' content='{{ seo_url }}{{ page.url | replace:'/index.html','/' }}' />
{% endif %}
{% if site.title %}
@ -64,10 +64,10 @@
{% if page.date %}
<meta property="og:type" content="article" />
{% if page.next.url %}
<link rel="next" href="{{ seo_url }}{{ page.next.url }}" title="{{ page.next.title | escape }}" />
<link rel="next" href="{{ seo_url }}{{ page.next.url | replace:'/index.html','/' }}" title="{{ page.next.title | escape }}" />
{% endif %}
{% if page.previous.url %}
<link rel="prev" href="{{ seo_url }}{{ page.previous.url }}" title="{{ page.previous.title | escape }}" />
<link rel="prev" href="{{ seo_url }}{{ page.previous.url | replace:'/index.html','/' }}" title="{{ page.previous.title | escape }}" />
{% endif %}
<script type="application/ld+json">
{

View File

@ -77,6 +77,15 @@ describe Jekyll::SeoTag do
expect(subject.render(context)).to match(expected)
end
it "uses replaces '/index.html' with '/'" do
page = page({ "permalink" => "/page/index.html" })
site = site({ "url" => "http://example.invalid" })
context = context({ :page => page, :site => site })
expected = %r!<link rel="canonical" href="http://example.invalid/page/" itemprop="url" />!
expected = %r!<meta property='og:url' content='http://example.invalid/page/' />!
expect(subject.render(context)).to match(expected)
end
it "outputs the site title meta" do
site = site({"title" => "Foo", "url" => "http://example.invalid"})
context = context({ :site => site })