Skip to content

Commit 23e9b8a

Browse files
committed
Replace '/index.html' with '/'
1 parent 9f3da7e commit 23e9b8a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/template.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
{% endif %}
4242

4343
{% if seo_url %}
44-
<link rel="canonical" href="{{ seo_url }}{{ page.url }}" itemprop="url" />
45-
<meta property='og:url' content='{{ seo_url }}{{ page.url }}' />
44+
<link rel="canonical" href="{{ seo_url }}{{ page.url | replace:'/index.html','/' }}" itemprop="url" />
45+
<meta property='og:url' content='{{ seo_url }}{{ page.url | replace:'/index.html','/' }}' />
4646
{% endif %}
4747

4848
{% if site.title %}
@@ -64,10 +64,10 @@
6464
{% if page.date %}
6565
<meta property="og:type" content="article" />
6666
{% if page.next.url %}
67-
<link rel="next" href="{{ seo_url }}{{ page.next.url }}" title="{{ page.next.title | escape }}" />
67+
<link rel="next" href="{{ seo_url }}{{ page.next.url | replace:'/index.html','/' }}" title="{{ page.next.title | escape }}" />
6868
{% endif %}
6969
{% if page.previous.url %}
70-
<link rel="prev" href="{{ seo_url }}{{ page.previous.url }}" title="{{ page.previous.title | escape }}" />
70+
<link rel="prev" href="{{ seo_url }}{{ page.previous.url | replace:'/index.html','/' }}" title="{{ page.previous.title | escape }}" />
7171
{% endif %}
7272
<script type="application/ld+json">
7373
{

spec/jekyll_seo_tag_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@
7777
expect(subject.render(context)).to match(expected)
7878
end
7979

80+
it "uses replaces '/index.html' with '/'" do
81+
page = page({ "permalink" => "/page/index.html" })
82+
site = site({ "url" => "http://example.invalid" })
83+
context = context({ :page => page, :site => site })
84+
expected = %r!<link rel="canonical" href="http://example.invalid/page/" itemprop="url" />!
85+
expected = %r!<meta property='og:url' content='http://example.invalid/page/' />!
86+
expect(subject.render(context)).to match(expected)
87+
end
88+
8089
it "outputs the site title meta" do
8190
site = site({"title" => "Foo", "url" => "http://example.invalid"})
8291
context = context({ :site => site })

0 commit comments

Comments
 (0)