Skip to content

Commit 7b43e40

Browse files
abelcheungdaattali
authored andcommitted
Fix showing background img with non-empty baseurl (daattali#497)
* Fix showing background img with non-empty baseurl Also switch globally to relative_url for all baseurl prepends, which is more robust than custom URL mangling * More site.baseurl -> relative_url conversion
1 parent a666a9d commit 7b43e40

12 files changed

Lines changed: 28 additions & 28 deletions

File tree

404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ <h1>Whoops, this page doesn't exist.</h1>
99
<h1>Move along. (404 error)</h1>
1010
<br/>
1111

12-
<img src="{{ site.baseurl }}/img/404-southpark.jpg" />
12+
<img src="{{ 'img/404-southpark.jpg' | relative_url }}" />
1313
</div>

_data/SocialNetworks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ telephone:
7373

7474
rss:
7575
name: "RSS"
76-
baseURL: "{{ '/feed.xml' | prepend: site.baseurl }}"
76+
baseURL: "{{ '/feed.xml' | relative_url }}"
7777
icon: "fa-rss"
7878

7979
steam:

_includes/footer-scripts.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
{% if page.js %}
1414
{% for js in page.js %}
15-
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script>
15+
<script src="{{ js | relative_url }}"></script>
1616
{% endfor %}
1717
{% endif %}
1818

@@ -22,11 +22,11 @@
2222
{% if js contains 'jquery' %}
2323
<script>
2424
if (typeof jQuery == 'undefined') {
25-
document.write('<script src="{{ js | prepend: site.baseurl | replace: "//", "/" }}"></scr' + 'ipt>');
25+
document.write('<script src="{{ js | relative_url }}"></scr' + 'ipt>');
2626
}
2727
</script>
2828
{% else %}
29-
<script src="{{ js | prepend: site.baseurl | replace: '//', '/' }}"></script>
29+
<script src="{{ js | relative_url }}"></script>
3030
{% endif %}
3131
{% endfor %}
3232
{% endif %}

_includes/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{%- assign element = site.data.SocialNetworks[curkey] -%}
99
<li>
1010
{%- if curkey == 'rss' -%}
11-
<a href="{{ '/feed.xml' | prepend: site.baseurl }}" title="{{ element.name }}">
11+
<a href="{{ '/feed.xml' | relative_url }}" title="{{ element.name }}">
1212
{%- elsif curkey == 'yelp' -%}
1313
<a href="https://{{ site.social-network-links[curkey] }}.yelp.com" title="{{ element.name }}">
1414
{%- else -%}

_includes/head.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<meta name="description" content="{{ page.subtitle }}">
1212
{% endif %}
1313

14-
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ site.baseurl }}/feed.xml" />
14+
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ '/feed.xml' | relative_url }}" />
1515

1616
{% include gtag.html %}
1717
{% include gtm_head.html %}
@@ -25,7 +25,7 @@
2525

2626
{% if layout.common-css %}
2727
{% for css in layout.common-css %}
28-
<link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" />
28+
<link rel="stylesheet" href="{{ css | relative_url }}" />
2929
{% endfor %}
3030
{% endif %}
3131

@@ -43,7 +43,7 @@
4343

4444
{% if page.css %}
4545
{% for css in page.css %}
46-
<link rel="stylesheet" href="{{ css | prepend: site.baseurl | replace: '//', '/' }}" />
46+
<link rel="stylesheet" href="{{ css | relative_url }}" />
4747
{% endfor %}
4848
{% endif %}
4949

@@ -125,7 +125,7 @@
125125

126126
{% if page.comments and site.staticman.repository and site.staticman.branch %}
127127
<!-- Staticman -->
128-
<link rel="stylesheet" href="{{ "/css/staticman.css" | prepend: site.baseurl }}" />
128+
<link rel="stylesheet" href="{{ "/css/staticman.css" | relative_url }}" />
129129
{% endif %}
130130

131131
</head>

_includes/header.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
{% assign imgnum = forloop.index %}
99
{% for imginfo in bigimg %}
1010
{% if imginfo[0] %}
11-
data-img-src-{{ imgnum }}="{{ imginfo[0] | prepend: site.baseurl | replace: '//', '/' }}"
11+
data-img-src-{{ imgnum }}="{{ imginfo[0] | relative_url }}"
1212
data-img-desc-{{ imgnum }}="{{ imginfo[1] }}"
1313
{% else %}
14-
data-img-src-{{ imgnum }}="{{ imginfo | prepend: site.baseurl | replace: '//', '/' }}"
14+
data-img-src-{{ imgnum }}="{{ imginfo | relative_url }}"
1515
{% endif %}
1616
{% endfor %}
1717
{% endfor %}

_includes/nav.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
<div class="avatar-container">
4242
<div class="avatar-img-border">
4343
<a href="{{ site.url }}">
44-
<img class="avatar-img" src="{{ page.image | prepend: site.baseurl | replace: '//', '/' }}" />
44+
<img class="avatar-img" src="{{ page.image | relative_url }}" />
4545
</a>
4646
</div>
4747
</div>
4848
{% elsif site.avatar and (layout.show-avatar or page.show-avatar) %}
4949
<div class="avatar-container">
5050
<div class="avatar-img-border">
5151
<a href="{{ site.url }}">
52-
<img class="avatar-img" src="{{ site.avatar | prepend: site.baseurl | replace: '//', '/' }}" />
52+
<img class="avatar-img" src="{{ site.avatar | relative_url }}" />
5353
</a>
5454
</div>
5555
</div>

_includes/navbarlink.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{% endif %}
99

1010
{% if internal %}
11-
{% capture linkurl %}{{ site.baseurl }}/{{ include.link[1] }}{% endcapture %}
11+
{% capture linkurl %}{{ include.link[1] | relative_url }}{% endcapture %}
1212
{% else %}
1313
{% capture linkurl %}{{ include.link[1] }}{% endcapture %}
1414
{% endif %}

_includes/staticman-script.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- doing something a bit funky here because I want to be careful not to include JQuery twice! -->
33
<script>
44
if (typeof jQuery == 'undefined') {
5-
document.write('<script src="{{ site.baseurl }}/js/jquery-1.11.2.min.js"></scr' + 'ipt>');
5+
document.write('<script src="{{ "/js/jquery-1.11.2.min.js" | relative_url }}"></scr' + 'ipt>');
66
}
77
</script>
88
<script>

_layouts/post.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
Tags:
4141
{% if site.link-tags %}
4242
{% for tag in page.tags %}
43-
<a href="{{ site.baseurl }}/tags#{{- tag -}}">{{- tag -}}</a>
43+
<a href="{{ '/tags' | relative_url }}#{{- tag -}}">{{- tag -}}</a>
4444
{% endfor %}
4545
{% else %}
4646
{{ page.tags | join: ", " }}
@@ -55,12 +55,12 @@
5555
<ul class="pager blog-pager">
5656
{% if page.previous.url %}
5757
<li class="previous">
58-
<a href="{{ page.previous.url | prepend: site.baseurl | replace: '//', '/' }}" data-toggle="tooltip" data-placement="top" title="{{page.previous.title}}">&larr; Previous Post</a>
58+
<a href="{{ page.previous.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.previous.title}}">&larr; Previous Post</a>
5959
</li>
6060
{% endif %}
6161
{% if page.next.url %}
6262
<li class="next">
63-
<a href="{{ page.next.url | prepend: site.baseurl | replace: '//', '/' }}" data-toggle="tooltip" data-placement="top" title="{{page.next.title}}">Next Post &rarr;</a>
63+
<a href="{{ page.next.url | relative_url }}" data-toggle="tooltip" data-placement="top" title="{{page.next.title}}">Next Post &rarr;</a>
6464
</li>
6565
{% endif %}
6666
</ul>

0 commit comments

Comments
 (0)