Skip to content

Commit

Permalink
Use site.baseurl to allow for local testing.
Browse files Browse the repository at this point in the history
Newer versions of Jekyll introduced the site.baseurl configuration
option [1], which is useful for testing the site locally. This commit adds
support for site.baseurl to this theme.

site.url is now used for the protocol and domain name only, without a
trailing slash. site.baseurl, if specified, has a leading slash and no
trailing slash.

In many instances, site.url has been replaced by site.baseurl where the
protocol and domain are not necessary (e.g., <a>, <img>, etc.). site.url
is now used in the following places:

- the canonical link
- the feed link and within the feed
- sharing, including Open Graph
- search

Some advice for where to use each comes from this StackOverflow post
[2], and other changes were based on the scaffolding generated by the
latest version of Jekyll (3.0.3).

[1]: https://jekyllrb.com/docs/upgrading/0-to-2/#baseurl
[2]: http://stackoverflow.com/a/27400343
  • Loading branch information
seanfisk committed Mar 14, 2016
1 parent 40071c0 commit 7196d77
Show file tree
Hide file tree
Showing 23 changed files with 81 additions and 91 deletions.
4 changes: 2 additions & 2 deletions 404.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ description: "Page not found. Your pixels are in another canvas."
comments: false
share: false
permalink: /404.html
---
---

Sorry, but the page you were trying to view does not exist --- perhaps you can try searching for it below.

<script type="text/javascript">
var GOOG_FIXURL_LANG = 'en';
var GOOG_FIXURL_SITE = '{{ site.url }}'
var GOOG_FIXURL_SITE = '{{ site.baseurl | prepend: site.url }}'
</script>
<script type="text/javascript"
src="//linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js">
Expand Down
5 changes: 2 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ disqus_shortname:
reading_time: true # if true, shows the estimated reading time for a post
words_per_minute: 200
logo: images/logo.png # logo visible in the topbar
# Your site's domain goes here (eg: //mmistakes.github.io, http://mademistakes.com, etc)
# When testing locally leave blank or use http://localhost:4000
# url: http://aronbordin.com/neo-hpstr-jekyll-theme
url: http://aronbordin.com # the base hostname & protocol for your site
baseurl: /neo-hpstr-jekyll-theme # the subpath of your site, e.g. /blog

# draw your top menu here
# each item must have a title and a url.
Expand Down
2 changes: 1 addition & 1 deletion _includes/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="read-more-content author-info">
<h3>{{site.owner.name}}</h3>
<div class="author-container">
<img class="author-img" src="{{site.url}}/{{site.owner.avatar}}" alt="{{site.owner.name}}" />
<img class="author-img" src="{{ site.baseurl }}/{{ site.owner.avatar }}" alt="{{site.owner.name}}" />
<div class="author-bio">{{site.owner.bio}}</div>
</div>
<div class="author-share">
Expand Down
2 changes: 1 addition & 1 deletion _includes/feed-footer.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
&lt;p&gt;&lt;a href=&quot;{{ site.url }}{{ post.url }}&quot;&gt;{{ post.title | xml_escape }}&lt;/a&gt; was originally published by {{ site.owner.name }} at &lt;a href=&quot;{{ site.url }}&quot;&gt;{{ site.title }}&lt;/a&gt; on {{ post.date | date: "%B %d, %Y" }}.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;{{ post.url | prepend: site.baseurl | prepend: site.url }}&quot;&gt;{{ post.title | xml_escape }}&lt;/a&gt; was originally published by {{ site.owner.name }} at &lt;a href=&quot;{{ site.baseurl | prepend: site.url }}&quot;&gt;{{ site.title }}&lt;/a&gt; on {{ post.date | date: "%B %d, %Y" }}.&lt;/p&gt;
20 changes: 9 additions & 11 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,37 @@
<meta property="og:type" content="article">
<meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}">
<meta property="og:description" content="{% if page.description %}{{ page.description }}{% else %}{{ site.description }}{% endif %}">
<meta property="og:url" content="{{ site.url }}{{ page.url }}">
<meta property="og:url" content="{{ page.url | prepend: site.baseurl | prepend: site.url }}">
<meta property="og:site_name" content="{{ site.title }}">
{% if page.image.feature %}<meta property="og:image" content="{{ site.url }}/images/{{ page.image.feature }}">
{% else %}<meta property="og:image" content="{% if page.image.thumb %}{{ site.url }}/images/{{ page.image.thumb }}{% else %}{{ site.url }}/images/{{ site.logo }}{% endif %}">{% endif %}
<meta property="og:image" content="{{ "/images/" | prepend: site.baseurl | prepend: site.url }}{% if page.image.feature %}{{ page.image.feature }}{% else %}{% if page.image.thumb %}{{ page.image.thumb }}{% else %}{{ site.logo }}{% endif %}{% endif %}">

{% if site.google_verify %}<meta name="google-site-verification" content="{{ site.google_verify }}">{% endif %}
{% if site.bing_verify %}<meta name="msvalidate.01" content="{{ site.bing_verify }}">{% endif %}

{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %}
<link rel="canonical" href="{{ canonical }}">
<link href="{{ site.url }}/feed.xml" type="application/atom+xml" rel="alternate" title="{{ site.title }} Feed">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" type="application/atom+xml" rel="alternate" title="{{ site.title }} Feed">

<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>

<!-- For all browsers -->
<link rel="stylesheet" href="{{ site.url }}/assets/css/main.css">
<link rel="stylesheet" href="{{ site.url }}/assets/css/jquery.mmenu.all.css">
<link rel="stylesheet" href="{{ site.url }}/assets/css/jquery.floating-social-share.min.css">
<link rel="stylesheet" href="{{ "/assets/css/main.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/assets/css/jquery.mmenu.all.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/assets/css/jquery.floating-social-share.min.css" | prepend: site.baseurl }}">
<!-- Webfonts -->
<link href="//fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic" rel="stylesheet" type="text/css">

<meta http-equiv="cleartype" content="on">

<!-- Load Modernizr -->
<script type="text/javascript" src="{{ site.url }}/assets/js/vendor/modernizr-2.6.2.custom.min.js"></script>
<script type="text/javascript" src="{{ "/assets/js/vendor/modernizr-2.6.2.custom.min.js" | prepend: site.baseurl }}"></script>

{% include icons.html %}

{% if page.image.background or site.background %}
{% capture background %}{% if page.image.background %}{{ page.image.background }}{% else %}{{ site.background }}{% endif %}{% endcapture %}
{% unless background contains 'http://' or background contains 'https://' %}{% capture background %}{{ site.url }}/images/{{ background }}{% endcapture %}{% endunless %}
{% unless background contains 'http://' or background contains 'https://' %}{% capture background %}{{ background | prepend: "/images/" | prepend: site.baseurl }}{% endcapture %}{% endunless %}
<style type="text/css">body {background-image:url({{ background }});}</style>
{% endif %}
26 changes: 13 additions & 13 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<ul class="header-item-container">
<li class="header-item-title header-toggle "><a href="#menu"><h2><i class="fa fa-bars"></i></h2></a></li>
<li class="header-item-title">
<a href="{{site.url}}/">
<a href="{{ site.baseurl }}/">
{% if site.logo %}
<img class="logo" src="{{site.url}}/{{ site.logo }}" alt="{{ site.title }}">
<img class="logo" src="{{ site.baseurl }}/{{ site.logo }}" alt="{{ site.title }}">
{% endif %}
<a href="{{site.url}}/" class="title"> {{ site.title }}</a>
<a href="{{ site.baseurl }}/" class="title"> {{ site.title }}</a>
</a>
</li>
{% for menu in site.menu reversed %}
Expand All @@ -19,7 +19,7 @@
{% endif %}

{% if menu.type == 'categories' %}
<li class="header-item {{class}}"><a href="{{site.url}}{{menu.url}}"><h3>{{ menu.title }}</h3></a>
<li class="header-item {{class}}"><a href="{{ site.baseurl }}{{ menu.url }}"><h3>{{ menu.title }}</h3></a>
<ul class="header-submenu">
{% for item in (0..site.categories.size) %}{% unless forloop.last %}
{% capture this_word %}{{ cats_list[item] | strip_newlines }}{% endcapture %}
Expand All @@ -28,22 +28,22 @@
</ul>
</li>
{% elsif menu.submenu %}
<li class="header-item {{class}}"><a href="{{site.url}}{{menu.url}}"><h3>{{ menu.title }}</h3></a>
<li class="header-item {{class}}"><a href="{{ site.baseurl }}{{ menu.url }}"><h3>{{ menu.title }}</h3></a>
<ul class="header-submenu">
{% for sub in menu.submenu %}
<li class="sub-item"><a href="{{site.url}}{{sub.url}}">{{sub.title}}</a></li>
<li class="sub-item"><a href="{{ site.baseurl }}{{ sub.url }}">{{sub.title}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
{% if menu.url contains 'http://' or menu.url contains 'https://' %}
<li class="header-item {{class}}"><a href="{{menu.url}}" target="_blank"><h3>{{ menu.title }}</h3></a></li>
{% else %}
<li class="header-item {{class}}"><a href="{{site.url}}{{menu.url}}"><h3>{{ menu.title }}</h3></a></li>
<li class="header-item {{class}}"><a href="{{ site.baseurl }}{{ menu.url }}"><h3>{{ menu.title }}</h3></a></li>
{% endif %}
{% endif %}
{% endfor %}
<li class="header-item"><a href="{{site.url}}/search"><h3><i class="fa fa-search"></i></h3></a></li>
<li class="header-item"><a href="{{ "/search" | prepend: site.baseurl }}"><h3><i class="fa fa-search"></i></h3></a></li>
</ul>
</div>
<div class="entry-header">
Expand Down Expand Up @@ -76,24 +76,24 @@ <h2><span class="entry-date"><time>&nbsp;</time></span></h2>
<ul>
{% for menu in site.menu %}
{% if menu.type == 'categories' %}
<li><a href="{{site.url}}{{menu.url}}"><h3>{{ menu.title }}</h3></a>
<li><a href="{{ site.baseurl }}{{ menu.url }}"><h3>{{ menu.title }}</h3></a>
<ul>
{% for item in (0..site.categories.size) %}{% unless forloop.last %}
{% capture this_word %}{{ cats_list[item] | strip_newlines }}{% endcapture %}
<li><a href="{{site.url}}/categories/#{{this_word}}">{{this_word}}</a></li>
<li><a href="{{ site.baseurl }}/categories/#{{this_word}}">{{this_word}}</a></li>
{% endunless %}{% endfor %}
</ul>
</li>
{% elsif menu.submenu %}
<li><a href="{{site.url}}{{menu.url}}"><h3>{{ menu.title }}</h3></a>
<li><a href="{{ site.baseurl }}{{ menu.url }}"><h3>{{ menu.title }}</h3></a>
<ul>
{% for sub in menu.submenu %}
<li><a href="{{site.url}}{{sub.url}}">{{sub.title}}</a></li>
<li><a href="{{ site.baseurl }}{{ sub.url }}">{{sub.title}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{site.url}}{{menu.url}}"><h3>{{ menu.title }}</h3></a></li>
<li><a href="{{ site.baseurl }}{{ menu.url }}"><h3>{{ menu.title }}</h3></a></li>
{% endif %}
{% endfor %}
</ul>
Expand Down
12 changes: 6 additions & 6 deletions _includes/icons.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Icons -->
<!-- 16x16 -->
<link rel="shortcut icon" href="{{ site.url }}/favicon.ico">
<link rel="shortcut icon" href="{{ "/favicon.ico" | prepend: site.baseurl }}">
<!-- 32x32 -->
<link rel="shortcut icon" href="{{ site.url }}/favicon.png">
<link rel="shortcut icon" href="{{ "/favicon.png" | prepend: site.baseurl }}">
<!-- 57x57 (precomposed) for iPhone 3GS, pre-2011 iPod Touch and older Android devices -->
<link rel="apple-touch-icon-precomposed" href="{{ site.url }}/images/apple-touch-icon-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="{{ "/images/apple-touch-icon-precomposed.png" | prepend: site.baseurl }}">
<!-- 72x72 (precomposed) for 1st generation iPad, iPad 2 and iPad mini -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ site.url }}/images/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ "/images/apple-touch-icon-72x72-precomposed.png" | prepend: site.baseurl }}">
<!-- 114x114 (precomposed) for iPhone 4, 4S, 5 and post-2011 iPod Touch -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ site.url }}/images/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ "/images/apple-touch-icon-114x114-precomposed.png" | prepend: site.baseurl }}">
<!-- 144x144 (precomposed) for iPad 3rd and 4th generation -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ site.url }}/images/apple-touch-icon-144x144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ "/images/apple-touch-icon-144x144-precomposed.png" | prepend: site.baseurl }}">
12 changes: 6 additions & 6 deletions _includes/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
{% comment %} Link for previous page {% endcomment %}
{% if paginator.previous_page %}
{% if paginator.previous_page == 1 %}
<li><a href="{{ site.url }}/" class="btn">Previous</a></li>
<li><a href="{{ site.baseurl }}/" class="btn">Previous</a></li>
{% else %}
<li><a href="{{ site.url }}/page{{ paginator.previous_page }}/" class="btn">Previous</a></li>
<li><a href="{{ site.baseurl }}/page{{ paginator.previous_page }}/" class="btn">Previous</a></li>
{% endif %}
{% endif %}

{% comment %} First page {% endcomment %}
{% if paginator.page == 1 %}
<li><strong class="current-page">1</strong></li>
{% else %}
<li><a href="{{ site.url }}/">1</a></li>
<li><a href="{{ site.baseurl }}/">1</a></li>
{% endif %}

{% assign page_start = 2 %}
Expand All @@ -40,7 +40,7 @@
{% comment %} Distance must be a positive value {% endcomment %}
{% assign dist = 0 | minus: dist %}
{% endif %}
<li><a href="{{ site.url }}/page{{ index }}/">{{index}}</a></li>
<li><a href="{{ site.baseurl }}/page{{ index }}/">{{index}}</a></li>
{% endif %}
{% endfor %}

Expand All @@ -52,14 +52,14 @@
{% if paginator.page == paginator.total_pages %}
<li><strong class="current-page">{{ paginator.page }}</strong></li>
{% else %}
<li><a href="{{ site.url }}/page{{ paginator.total_pages }}/">{{ paginator.total_pages }}</a></li>
<li><a href="{{ site.baseurl }}/page{{ paginator.total_pages }}/">{{ paginator.total_pages }}</a></li>
{% endif %}

{% comment %}
Link next page
{% endcomment %}
{% if paginator.next_page %}
<li><a href="{{ site.url }}/page{{ paginator.next_page }}/" class="btn">Next</a></li>
<li><a href="{{ site.baseurl }}/page{{ paginator.next_page }}/" class="btn">Next</a></li>
{% endif %}
</ul>
</div>
Expand Down
8 changes: 4 additions & 4 deletions _includes/read-more.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="read-more">
{% for post in site.related_posts limit:1 %}
<div class="read-more-header">
<a href="{{ site.url }}{{ page.previous.url }}" class="read-more-btn">Read More</a>
<a href="{{ site.baseurl }}{{ page.previous.url }}" class="read-more-btn">Read More</a>
</div><!-- /.read-more-header -->
<div class="read-more-content">
<h3><a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h3>
<p>{% if post.description %}{{ post.description }}{% else %}{{ post.content | strip_html | strip_newlines | truncate: 140 }}&hellip;{% endif %} <a href="{{ site.url }}{{ post.url }}">Continue reading</a></p>
<h3><a href="{{ site.baseurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h3>
<p>{% if post.description %}{{ post.description }}{% else %}{{ post.content | strip_html | strip_newlines | truncate: 140 }}&hellip;{% endif %} <a href="{{ site.baseurl }}{{ post.url }}">Continue reading</a></p>
</div><!-- /.read-more-content -->
{% endfor %}
<div class="read-more-list">
{% for post in site.related_posts limit:2 offset:1 %}
<div class="list-item">
<h4><a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h4>
<h4><a href="{{ site.baseurl }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></h4>
<span>Published on {{ post.date | date: "%B %d, %Y" }}</span>
</div><!-- /.list-item -->
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="{{ site.url }}/assets/js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
<script type="text/javascript" src="{{ site.url }}/assets/js/scripts.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="{{ "/assets/js/vendor/jquery-1.9.1.min.js" | prepend: site.baseurl }}"><\/script>')</script>
<script type="text/javascript" src="{{ "/assets/js/scripts.min.js" | prepend: site.baseurl }}"></script>
<script type="text/javascript" async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
<script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

Expand Down
8 changes: 4 additions & 4 deletions _includes/social-share.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="social-share">
{% capture shareurl %}{{ page.url | prepend: site.baseurl | prepend: site.url }}{% endcapture %}<div class="social-share">
<ul class="socialcount socialcount-small inline-list">
<li class="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u={{ site.url }}{{ page.url }}" title="Share on Facebook"><span class="count"><i class="fa fa-facebook-square"></i> Like</span></a></li>
<li class="twitter"><a href="https://twitter.com/intent/tweet?text={{ site.url }}{{ page.url }}" title="Share on Twitter"><span class="count"><i class="fa fa-twitter-square"></i> Tweet</span></a></li>
<li class="googleplus"><a href="https://plus.google.com/share?url={{ site.url }}{{ page.url }}" title="Share on Google Plus"><span class="count"><i class="fa fa-google-plus-square"></i> +1</span></a></li>
<li class="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u={{ shareurl }}" title="Share on Facebook"><span class="count"><i class="fa fa-facebook-square"></i> Like</span></a></li>
<li class="twitter"><a href="https://twitter.com/intent/tweet?text={{ shareurl }}" title="Share on Twitter"><span class="count"><i class="fa fa-twitter-square"></i> Tweet</span></a></li>
<li class="googleplus"><a href="https://plus.google.com/share?url={{ shareurl }}" title="Share on Google Plus"><span class="count"><i class="fa fa-google-plus-square"></i> +1</span></a></li>
</ul>
</div><!-- /.social-share -->
4 changes: 2 additions & 2 deletions _layouts/dark-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
<div class="entry-content">
{% if page.image.feature %}
<div class="entry-image-index">
<img src="{{ site.url }}/images/{{ page.image.feature }}" alt="{{ page.title }}">
<img src="{{ site.baseurl }}/images/{{ page.image.feature }}" alt="{{ page.title }}">
{% if page.image.credit %}<div class="image-credit">Image source: <a target="_blank" href="{{ page.image.creditlink }}">{{ page.image.credit }}</a></div><!-- /.image-credit -->{% endif %}
</div>
{% endif %}
<h1 class="post-title entry-title">{{ page.title }}</h1>
{{ content }}
<footer class="entry-meta">
<span class="entry-tags">{% for tag in page.tags %}<a href="{{ site.url }}/tags#{{ tag }}" title="Pages tagged {{ tag }}" class="tag"><span class="term">{{ tag }}</span></a>{% unless forloop.last %}{% endunless %}{% endfor %}</span>
<span class="entry-tags">{% for tag in page.tags %}<a href="{{ site.baseurl }}/tags#{{ tag }}" title="Pages tagged {{ tag }}" class="tag"><span class="term">{{ tag }}</span></a>{% unless forloop.last %}{% endunless %}{% endfor %}</span>
{% if page.modified %}<span>Updated on <span class="entry-date date updated"><time datetime="{{ page.modified }}">{{ page.modified | date: "%B %d, %Y" }}</time></span></span>
{% endif %}
<span class="author vcard"><span class="fn">{{ site.owner.name }}</span></span>
Expand Down
Loading

0 comments on commit 7196d77

Please sign in to comment.