Skip to content

Commit

Permalink
Fix: added baseurl to image paths
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskyfung committed Sep 29, 2020
1 parent c780369 commit 76fd785
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
14 changes: 7 additions & 7 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ paginate: 12
paginate_path: "/blog/page:num/"
permalink: /blog/:year/:month/:day/:title
timezone: 'Asia/Hong_Kong'
baseurl: ''
baseurl: '/amp-affiliately-jekyll-theme'
email: ''
google_analytics: ''
gtm: '' # Google Tag Manager ID
adsense: '' # Google Adsense ID
google_analytics: 'UA-72575541-9'
gtm: 'GTM-WQMQK3X' # Google Tag Manager ID
cse_id: 011006674894885990812:tjln7k0nyjx # Google Custom Search Engine ID
adsense: 'ca-pub-4819282024314540' # Google Adsense ID
disqus: ''
disqus_amp_baseurl: 'https://' #baseurl of your AMP disqus iframe element
addthis:
cse_id: # Google Custom Search Engine ID
buyme:
addthis: ra-5d01c83d522ad580
buyme: chrisfungky
sidebar:
featured: true
recent_posts: true
Expand Down
6 changes: 3 additions & 3 deletions _includes/picture.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
{% assign lightbox = "" %}
{% endif %}
{% if ext == "svg" %}
<amp-img {{ lightbox }} alt="{{ include.alt }}" width="{{ include.width | default: 730 }}" height="{{ include.height }}" layout="{{ layout | default: "intrinsic" }}" src="{{ path }}{{ img }}"></amp-img>
<amp-img {{ lightbox }} alt="{{ include.alt }}" width="{{ include.width | default: 730 }}" height="{{ include.height }}" layout="{{ layout | default: "intrinsic" }}" src="{{ site.baseurl }}{{ path }}{{ img }}"></amp-img>
{% else %}
<amp-img {{ lightbox }} alt="{{ include.alt }}" width="{{ include.width | default: 730 }}" height="{{ include.height }}" layout="{{ layout | default: "intrinsic" }}" src="{{ path }}{{ name }}{{ suffix }}webp">
<amp-img fallback {{ lightbox }} alt="{{ include.alt }}" width="{{ include.width | default: 730 }}" height="{{ include.height }}" layout="{{ layout | default: "intrinsic" }}" src="{{ path }}{{ name }}{{ suffix }}{{ ext }}"></amp-img>
<amp-img {{ lightbox }} alt="{{ include.alt }}" width="{{ include.width | default: 730 }}" height="{{ include.height }}" layout="{{ layout | default: "intrinsic" }}" src="{{ site.baseurl }}{{ path }}{{ name }}{{ suffix }}webp">
<amp-img fallback {{ lightbox }} alt="{{ include.alt }}" width="{{ include.width | default: 730 }}" height="{{ include.height }}" layout="{{ layout | default: "intrinsic" }}" src="{{ site.baseurl }}{{ path }}{{ name }}{{ suffix }}{{ ext }}"></amp-img>
</amp-img>
{% endif %}
{% if include.link %}
Expand Down
4 changes: 2 additions & 2 deletions _includes/youtube-thumb.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<a href="https://youtu.be/{{ include.id }}" target="_blank">
</figure>
<amp-img width="246" height="138" layout="intrinsic" src="/assets/images/{{include.id }}.webp" alt="{{ include.title }}" style="border:1px solid #eee">
<amp-img fallback width="246" height="138" layout="intrinsic" src="assets/images/{{include.id }}.jpg"></amp-img>
<amp-img width="246" height="138" layout="intrinsic" src="{{ site.baseurl }}/assets/images/{{include.id }}.webp" alt="{{ include.title }}" style="border:1px solid #eee">
<amp-img fallback width="246" height="138" layout="intrinsic" src="{{ site.baseurl }}/assets/images/{{include.id }}.jpg"></amp-img>
</amp-img>
<figcaption><b>{{ include.title }}</b></figcaption>
</figure>
Expand Down
38 changes: 19 additions & 19 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<body class="{{ layout }}">

<!-- Google Tag Manager -->
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-WQMQK3X&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics>
<amp-auto-ads type="adsense" data-ad-client="ca-pub-4819282024314540" data-full-width>
<amp-analytics config="https://www.googletagmanager.com/amp.json?id={{ site.gtm }}&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics>
<amp-auto-ads type="adsense" data-ad-client="{{ site.adsense }}" data-full-width>
<div placeholder>Loading Ads...</div>
<div fallback></div>
<div overflow></div>
Expand All @@ -88,7 +88,7 @@
<div class="container">

<!-- Begin Logo -->
<a class="navbar-brand" href="{{ site.baseurl }}/">
<a class="navbar-brand" href="/">
<amp-img src="{{ site.baseurl }}/{{ site.logo }}" alt="{{ site.name }}" height="36" width="140"></amp-img>
</a>
<!-- End Logo -->
Expand All @@ -100,24 +100,24 @@
<ul class="navbar-nav ml-auto">

<li class="nav-item">
<a class="nav-link" href="{{ site.baseurl }}/">Home</a>
<a class="nav-link" href="/">Home</a>
</li>

<li class="nav-item dropdown" id="dropdown01">
<a class="nav-link dropdown-toggle" on="tap:dropdown01.toggleClass(class='show'),navbar.toggleClass(class='show')" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Blog</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="{{ site.baseurl }}/blog/"><i class="far fa-newspaper mr-2"></i>All Stories</a>
<a class="dropdown-item" href="{{ site.baseurl }}/category/"><i class="far fa-list-alt mr-2"></i>Categories</a>
<a class="dropdown-item" href="{{ site.baseurl }}/tag/"><i class="fas fa-tag mr-2"></i>Tags</a>
<a class="dropdown-item" href="/blog/"><i class="far fa-newspaper mr-2"></i>All Stories</a>
<a class="dropdown-item" href="/category/"><i class="far fa-list-alt mr-2"></i>Categories</a>
<a class="dropdown-item" href="/tag/"><i class="fas fa-tag mr-2"></i>Tags</a>
</div>
</li>

<li class="nav-item">
<a class="nav-link" href="{{ site.baseurl }}/category/cloud/">Cloud</a>
<a class="nav-link" href="/category/cloud/">Cloud</a>
</li>

<li class="nav-item">
<a class="nav-link" href="{{ site.baseurl }}/category/academic/">Academic</a>
<a class="nav-link" href="/category/academic/">Academic</a>
</li>

<li class="nav-item">
Expand Down Expand Up @@ -150,7 +150,7 @@ <h5 class="modal-title">Search for</h5>
</div>
<div class="modal-body">
<div class="search_form">
<form method="GET" action="/search" target="_top">
<form method="GET" action="{{ site.baseurl }}/search" target="_top">
<amp-autocomplete id="searchbox" filter="substring" src="/assets/data/suggestions.json">
<input class="form-control" name="q" type="search" placeholder="Search" required />
</amp-autocomplete>
Expand Down Expand Up @@ -195,7 +195,7 @@ <h5 class="modal-title">Search for</h5>
<h3>Want to talk about a new or existing project?</h3>
<p>See anything that can be improved?</p>
<p>Feel free to send me a message using the form below. I will get back to you as soon as possible!</p>
<a class="btn btn-primary btn-lg" href="{{ site.baseurl }}/contact">Contact Me</a>
<a class="btn btn-primary btn-lg" href="/contact">Contact Me</a>
</div>
<div class="col-md-4 text-center footersocial">
<div class="mb-4">
Expand All @@ -222,7 +222,7 @@ <h5>Follow Me on</h5>
<div class="row">
<div class="col-sm-3">
<div class="footer-widget">
<a id="footer-image" href="{{site.baseurl}}">
<a id="footer-image" href="/">
<amp-img class="pr-lg-3" src="{{ site.baseurl }}/assets/images/knowledge__flatline.svg" height="179" width="255" layout="responsive"></amp-img>
</a>
</div>
Expand All @@ -232,10 +232,10 @@ <h5>Follow Me on</h5>
<div class="footer-widget">
<h5 class="title">Quick Links</h5>
<ul>
<li><a href="{{ site.baseurl }}/tag/qwiklabs">Qwiklabs Logbooks & Tools</a></li>
<li><a href="{{ site.baseurl }}/tag/tumblr">For Tumblr Developer</a></li>
<li><a href="{{ site.baseurl }}/tag/matlab">MATLAB Tips</a></li>
<li><a href="{{ site.baseurl }}/tag/evernote/">Evernote Tips</a></li>
<li><a href="/tag/qwiklabs">Qwiklabs Logbooks & Tools</a></li>
<li><a href="/tag/tumblr">For Tumblr Developer</a></li>
<li><a href="/tag/matlab">MATLAB Tips</a></li>
<li><a href="/tag/evernote/">Evernote Tips</a></li>
<li></li>
</ul>
</div>
Expand All @@ -245,9 +245,9 @@ <h5 class="title">Quick Links</h5>
<div class="footer-widget">
<h5 class="title">Author</h5>
<ul>
<li><a href="{{ site.baseurl }}/about">About Me</a></li>
<li><a href="{{ site.baseurl }}/#projects">My Projects</a></li>
<li><a href="{{ site.baseurl }}/contact">Contact</a></li>
<li><a href="/about">About Me</a></li>
<li><a href="/#projects">My Projects</a></li>
<li><a href="/contact">Contact</a></li>
<li><a href="https://invitation.codes/@chriskyfung" data-type="badge1" target="_blank" rel="noopener noreferrer">Referral codes</a></li>
</ul>
</div>
Expand Down
6 changes: 3 additions & 3 deletions _layouts/post-left-sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ <h1 class="posttitle">{{ page.title }}</h1>
{% if page.image %}
{% unless page.image.hide %}
{% if page.image.ext == "svg" %}
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="/images/posts/{{ page.image.path }}.svg" alt="{{ page.title }}"></amp-img>
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ site.baseurl }}{{ page.image.path }}.svg" alt="{{ page.title }}"></amp-img>
{% else %}
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="/images/posts/{{ page.image.path }}.webp" alt="{{ page.title }}">
<amp-img fallback class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="/images/posts/{{ page.image.path }}.{{ page.image.ext }}" alt="{{ page.title }}"></amp-img>
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ site.baseurl }}{{ page.image.path }}.webp" alt="{{ page.title }}">
<amp-img fallback class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ site.baseurl }}{{ page.image.path }}.{{ page.image.ext }}" alt="{{ page.title }}"></amp-img>
</amp-img>
{% endif %}
{% endunless %}
Expand Down
6 changes: 3 additions & 3 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ <h1 class="posttitle">{{ page.title }}</h1>
{% assign imgpath = page.image.path | remove: imgext %}
{% unless page.image.hide %}
{% if imgext == "svg" %}
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ page.image.path }}" alt="{{ page.title }}"></amp-img>
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ site.baseurl }}{{ page.image.path }}" alt="{{ page.title }}"></amp-img>
{% else %}
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ imgpath }}webp" alt="{{ page.title }}">
<amp-img fallback class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ page.image.path }}" alt="{{ page.title }}"></amp-img>
<amp-img class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ site.baseurl }}{{ imgpath }}webp" alt="{{ page.title }}">
<amp-img fallback class="featured-image {{ page.image.class }}" width="{{ page.image.width | default: 730 }}" height="{{ page.image.height | default: 411 }}" layout="responsive" src="{{ site.baseurl }}{{ page.image.path }}" alt="{{ page.title }}"></amp-img>
</amp-img>
{% endif %}
{% endunless %}
Expand Down

1 comment on commit 76fd785

@chriskyfung
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 Bug fixes

  • (picture.html, post.html, post-left-sidebar.html): fix broken images by adding the base URL to the image URLs

♻️ Refactor

  • (default.html): replaced hardcoded values with site-level variables

🔧 Chores

  • (_config.yml): set /amp-affiliately-jekyll-theme as base URL of the project page
  • (_config.yml): configured google_analytics, gtm, cse_id, adsense, addthis and buyme variables for third-party elements

Please sign in to comment.