Abs link patch (#506)

* Fix absolute URL generation

url and baseurl config for this theme deviates from jekyll standard,
and that results in double inclusion of project path
if this theme is used as project page.

Switching to Jekyll accepted url usage so that
absolute_url filter works.

* Alternate links need to be aboslute

* mention url and baseurl only need to be modified in local dev

* Update readme on new url/baseurl setting changes
This commit is contained in:
Abel Cheung 2019-06-21 15:48:52 +08:00 committed by Dean Attali
parent 7061f6be17
commit 9d429fa749
10 changed files with 52 additions and 42 deletions

View file

@ -8,7 +8,7 @@
js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.12&appId={{ site.fb_comment_id }}&autoLogAppEvents=1';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="{{ site.url }}{{ page.url }}" data-width="100%" data-numposts="5"></div>
<div class="fb-comments" data-href="{{ page.url | absolute_url }}" data-width="100%" data-numposts="5"></div>
<noscript>Please enable JavaScript to view the comments powered by Facebook.</noscript>
</div>
{%- endif -%}

View file

@ -7,10 +7,10 @@
{% else %}
{{ site.time | date: '%Y' }}
{% endif %}
{% if site.url-pretty %}
&nbsp;&nbsp;&bull;&nbsp;&nbsp;
<a href="{{ site.url }}">{{ site.url-pretty }}</a>
{% endif %}
<a href="{{ '' | absolute_url }}">{{ site.url-pretty }}</a>
{% endif %}
</div>
</footer>

View file

@ -30,7 +30,7 @@
{% if site.url-pretty %}
&nbsp;&bull;&nbsp;
<a href="{{ site.url }}">{{ site.url-pretty }}</a>
<a href="{{ '' | absolute_url }}">{{ site.url-pretty }}</a>
{% endif %}
{% if site.matomo %}

View file

@ -11,7 +11,7 @@
<meta name="description" content="{{ page.subtitle }}">
{% endif %}
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ '/feed.xml' | relative_url }}" />
<link rel="alternate" type="application/rss+xml" title="{{ site.title }} {{ site.title-separator }} {{ site.description }}" href="{{ '/feed.xml' | absolute_url }}" />
{% include gtag.html %}
{% include gtm_head.html %}
@ -78,17 +78,17 @@
<meta property="og:type" content="website" />
{% if page.id %}
<meta property="og:url" content="{{ site.url }}{{ page.url }}" />
<link rel="canonical" href="{{ site.url }}{{ page.url }}" />
<meta property="og:url" content="{{ page.url | absolute_url }}" />
<link rel="canonical" href="{{ page.url | absolute_url }}" />
{% else %}
<meta property="og:url" content="{{ site.url }}{{ page.url | remove: '/index.html' | remove: '.html' }}" />
<link rel="canonical" href="{{ site.url }}{{ page.url | remove: '/index.html' | remove: '.html' }}" />
<meta property="og:url" content="{{ page.url | absolute_url | strip_index }}" />
<link rel="canonical" href="{{ page.url | absolute_url | strip_index }}" />
{% endif %}
{% if page.share-img %}
<meta property="og:image" content="{{ page.share-img }}" />
{% elsif site.avatar %}
<meta property="og:image" content="{{ site.url }}{{ site.avatar }}" />
<meta property="og:image" content="{{ site.avatar | absolute_url }}" />
{% endif %}
@ -116,7 +116,7 @@
{% if page.share-img %}
<meta name="twitter:image" content="{{ page.share-img }}" />
{% elsif site.avatar %}
<meta name="twitter:image" content="{{ site.url }}{{ site.avatar }}" />
<meta name="twitter:image" content="{{ site.avatar | absolute_url }}" />
{% endif %}
{% if site.matomo %}

View file

@ -8,9 +8,9 @@
<span class="icon-bar"></span>
</button>
{% if site.title-img %}
<a class="navbar-brand navbar-brand-logo" href="{{ site.url }}"><img src="{{ site.title-img }}"/></a>
<a class="navbar-brand navbar-brand-logo" href="{{ '' | absolute_url }}"><img src="{{ site.title-img }}"/></a>
{% else %}
<a class="navbar-brand" href="{{ site.url }}">{{ site.title }}</a>
<a class="navbar-brand" href="{{ '' | absolute_url }}">{{ site.title }}</a>
{% endif %}
</div>
@ -40,7 +40,7 @@
{% if page.image and (layout.show-avatar or page.show-avatar) %}
<div class="avatar-container">
<div class="avatar-img-border">
<a href="{{ site.url }}">
<a href="{{ '' | absolute_url }}">
<img class="avatar-img" src="{{ page.image | relative_url }}" />
</a>
</div>
@ -48,7 +48,7 @@
{% elsif site.avatar and (layout.show-avatar or page.show-avatar) %}
<div class="avatar-container">
<div class="avatar-img-border">
<a href="{{ site.url }}">
<a href="{{ '' | absolute_url }}">
<img class="avatar-img" src="{{ site.avatar | relative_url }}" />
</a>
</div>

View file

@ -12,7 +12,7 @@
{% if site.share-links-active.twitter %}
<!--- Share on Twitter -->
<a href="https://twitter.com/intent/tweet?text={{ page.title | url_encode }}+{{ site.url }}{{ page.url }}"
<a href="https://twitter.com/intent/tweet?text={{ page.title | url_encode }}&url={{ page.url | absolute_url | url_encode }}"
class="btn btn-social-icon btn-twitter" title="Share on Twitter">
<span class="fa fa-fw fa-twitter" aria-hidden="true"></span>
<span class="sr-only">Twitter</span>
@ -21,7 +21,7 @@
{% if site.share-links-active.facebook %}
<!--- Share on Facebook -->
<a href="https://www.facebook.com/sharer/sharer.php?u={{ site.url }}{{ page.url }}"
<a href="https://www.facebook.com/sharer/sharer.php?u={{ page.url | absolute_url | url_encode }}"
class="btn btn-social-icon btn-facebook" title="Share on Facebook">
<span class="fa fa-fw fa-facebook" aria-hidden="true"></span>
<span class="sr-only">Facebook</span>
@ -30,7 +30,7 @@
{% if site.share-links-active.linkedin %}
<!--- Share on LinkedIn -->
<a href="https://www.linkedin.com/shareArticle?mini=true&url={{ site.url }}{{ page.url }}"
<a href="https://www.linkedin.com/shareArticle?mini=true&url={{ page.url | absolute_url | url_encode }}"
class="btn btn-social-icon btn-linkedin" title="Share on LinkedIn">
<span class="fa fa-fw fa-linkedin" aria-hidden="true"></span>
<span class="sr-only">LinkedIn</span>