Skip to content

Commit

Permalink
Replace absolute_url with relative_url
Browse files Browse the repository at this point in the history
Where it makes sense replace asset paths and navigation related paths with `relative_url` filter.

Leave SEO related `<head>` elements and social sharing links as `absolute_url`.

Fixes mmistakes#1588
  • Loading branch information
mmistakes committed Mar 20, 2018
1 parent c3e8691 commit 8a42842
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
## Unreleased

### Enhancements

* Add default `theme` and `remote_theme` values to `_config.yml`.

### Bug Fixes

* Replace `absolute_url` filter with `relative_url` where it makes sense (asset/nagivation related paths). [#1588](https://github.com/mmistakes/minimal-mistakes/issues/1588)

## [4.10.1](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.10.1)

### Enhancements
Expand Down
6 changes: 3 additions & 3 deletions _includes/archive-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
{% if teaser contains "://" %}
"{{ teaser }}"
{% else %}
"{{ teaser | absolute_url }}"
"{{ teaser | relative_url }}"
{% endif %}
alt="">
</div>
{% endif %}
<h2 class="archive__item-title" itemprop="headline">
{% if post.link %}
<a href="{{ post.link }}">{{ title }}</a> <a href="{{ post.url | absolute_url }}" rel="permalink"><i class="fas fa-link" aria-hidden="true" title="permalink"></i><span class="sr-only">Permalink</span></a>
<a href="{{ post.link }}">{{ title }}</a> <a href="{{ post.url | relative_url }}" rel="permalink"><i class="fas fa-link" aria-hidden="true" title="permalink"></i><span class="sr-only">Permalink</span></a>
{% else %}
<a href="{{ post.url | absolute_url }}" rel="permalink">{{ title }}</a>
<a href="{{ post.url | relative_url }}" rel="permalink">{{ title }}</a>
{% endif %}
</h2>
{% if post.read_time %}
Expand Down
4 changes: 2 additions & 2 deletions _includes/author-profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
{% if author.avatar contains "://" %}
{% assign author_src = author.avatar %}
{% else %}
{% assign author_src = author.avatar | absolute_url %}
{% assign author_src = author.avatar | relative_url %}
{% endif %}

{% if author.home %}
{% if author.home contains "://" %}
{% assign author_link = author.home %}
{% else %}
{% assign author_link = author.home | absolute_url %}
{% assign author_link = author.home | relative_url %}
{% endif %}
<a href="{{ author_link }}">
<img src="{{ author_src }}" alt="{{ author.name }}" itemprop="image">
Expand Down
2 changes: 1 addition & 1 deletion _includes/breadcrumbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{% else %}
{% assign i = i | plus: 1 %}
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="{{ crumb | downcase | replace: '%20', '-' | prepend: path_type | prepend: crumb_path | absolute_url }}" itemprop="item"><span itemprop="name">{{ crumb | replace: '-', ' ' | replace: '%20', ' ' | capitalize }}</span></a>
<a href="{{ crumb | downcase | replace: '%20', '-' | prepend: path_type | prepend: crumb_path | relative_url }}" itemprop="item"><span itemprop="name">{{ crumb | replace: '-', ' ' | replace: '%20', ' ' | capitalize }}</span></a>
<meta itemprop="position" content="{{ i }}" />
</li>
<span class="sep">{{ site.data.ui-text[site.locale].breadcrumb_separator | default: "/" }}</span>
Expand Down
2 changes: 1 addition & 1 deletion _includes/category-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% for hash in category_hashes %}
{% assign keyValue = hash | split: '#' %}
{% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
<a href="{{ category_word | slugify | prepend: path_type | prepend: site.category_archive.path | absolute_url }}" class="page__taxonomy-item" rel="tag">{{ category_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
<a href="{{ category_word | slugify | prepend: path_type | prepend: site.category_archive.path | relative_url }}" class="page__taxonomy-item" rel="tag">{{ category_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
{% endfor %}
</span>
</p>
Expand Down
4 changes: 2 additions & 2 deletions _includes/feature_row
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% if f.url contains "://" %}
{% capture f_url %}{{ f.url }}{% endcapture %}
{% else %}
{% capture f_url %}{{ f.url | absolute_url }}{% endcapture %}
{% capture f_url %}{{ f.url | relative_url }}{% endcapture %}
{% endif %}

<div class="feature__item{% if include.type %}--{{ include.type }}{% endif %}">
Expand All @@ -22,7 +22,7 @@
{% if f.image_path contains "://" %}
"{{ f.image_path }}"
{% else %}
"{{ f.image_path | absolute_url }}"
"{{ f.image_path | relative_url }}"
{% endif %}
alt="{% if f.alt %}{{ f.alt }}{% endif %}">
</div>
Expand Down
2 changes: 1 addition & 1 deletion _includes/figure
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% if include.image_path contains "://" %}
"{{ include.image_path }}"
{% else %}
"{{ include.image_path | absolute_url }}"
"{{ include.image_path | relative_url }}"
{% endif %}
alt="{% if include.alt %}{{ include.alt }}{% endif %}">
{% if include.caption %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% if site.author.bitbucket %}
<li><a href="https://bitbucket.org/{{ site.author.bitbucket }}"><i class="fab fa-fw fa-bitbucket" aria-hidden="true"></i> Bitbucket</a></li>
{% endif %}
<li><a href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | absolute_url }}{% endif %}"><i class="fas fa-fw fa-rss-square" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].feed_label | default: "Feed" }}</a></li>
<li><a href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | relative_url }}{% endif %}"><i class="fas fa-fw fa-rss-square" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].feed_label | default: "Feed" }}</a></li>
</ul>
</div>

Expand Down
6 changes: 3 additions & 3 deletions _includes/gallery
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
{% if img.url contains "://" %}
"{{ img.url }}"
{% else %}
"{{ img.url | absolute_url }}"
"{{ img.url | relative_url }}"
{% endif %}
{% if img.title %}title="{{ img.title }}"{% endif %}
>
<img src=
{% if img.image_path contains "://" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | absolute_url }}"
"{{ img.image_path | relative_url }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
</a>
Expand All @@ -36,7 +36,7 @@
{% if img.image_path contains "://" %}
"{{ img.image_path }}"
{% else %}
"{{ img.image_path | absolute_url }}"
"{{ img.image_path | relative_url }}"
{% endif %}
alt="{% if img.alt %}{{ img.alt }}{% endif %}">
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% include seo.html %}

<link href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | absolute_url }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ site.title }} Feed">
<link href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | relative_url }}{% endif %}" type="application/atom+xml" rel="alternate" title="{{ site.title }} Feed">

<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
Expand All @@ -14,7 +14,7 @@
</script>

<!-- For all browsers -->
<link rel="stylesheet" href="{{ '/assets/css/main.css' | absolute_url }}">
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">

<!--[if lte IE 9]>
<style>
Expand All @@ -36,7 +36,7 @@
{% if script contains "://" %}
{% capture script_path %}{{ script }}{% endcapture %}
{% else %}
{% capture script_path %}{{ script | absolute_url }}{% endcapture %}
{% capture script_path %}{{ script | relative_url }}{% endcapture %}
{% endif %}
<script src="{{ script_path }}"></script>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/masthead.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="masthead__inner-wrap">
<div class="masthead__menu">
<nav id="site-nav" class="greedy-nav">
<a class="site-title" href="{{ '/' | absolute_url }}">{{ site.title }}</a>
<a class="site-title" href="{{ '/' | relative_url }}">{{ site.title }}</a>
<ul class="visible-links">
{% for link in site.data.navigation.main %}
{% if link.url contains 'http' %}
Expand Down
6 changes: 3 additions & 3 deletions _includes/page__hero.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{% if page.header.image contains "://" %}
{% capture img_path %}{{ page.header.image }}{% endcapture %}
{% else %}
{% capture img_path %}{{ page.header.image | absolute_url }}{% endcapture %}
{% capture img_path %}{{ page.header.image | relative_url }}{% endcapture %}
{% endif %}

{% if page.header.cta_url contains "://" %}
{% capture cta_path %}{{ page.header.cta_url }}{% endcapture %}
{% else %}
{% capture cta_path %}{{ page.header.cta_url | absolute_url }}{% endcapture %}
{% capture cta_path %}{{ page.header.cta_url | relative_url }}{% endcapture %}
{% endif %}

{% if page.header.overlay_image contains "://" %}
{% capture overlay_img_path %}{{ page.header.overlay_image }}{% endcapture %}
{% elsif page.header.overlay_image %}
{% capture overlay_img_path %}{{ page.header.overlay_image | absolute_url }}{% endcapture %}
{% capture overlay_img_path %}{{ page.header.overlay_image | relative_url }}{% endcapture %}
{% endif %}

{% if page.header.overlay_filter contains "rgba" %}
Expand Down
12 changes: 6 additions & 6 deletions _includes/paginator.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% if paginator.total_pages > 1 %}
<nav class="pagination">
{% assign first_page_path = site.paginate_path | replace: 'page:num', '' | replace: '//', '/' | absolute_url %}
{% assign first_page_path = site.paginate_path | replace: 'page:num', '' | replace: '//', '/' | relative_url %}
<ul>
{% comment %} Link for previous page {% endcomment %}
{% if paginator.previous_page %}
{% if paginator.previous_page == 1 %}
<li><a href="{{ first_page_path }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
{% else %}
<li><a href="{{ site.paginate_path | replace: ':num', paginator.previous_page | replace: '//', '/' | absolute_url }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
<li><a href="{{ site.paginate_path | replace: ':num', paginator.previous_page | replace: '//', '/' | relative_url }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a></li>
{% endif %}
{% else %}
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</span></a></li>
Expand Down Expand Up @@ -35,15 +35,15 @@

{% for index in (page_start..page_end) %}
{% if index == paginator.page %}
<li><a href="{{ site.paginate_path | replace: ':num', index | replace: '//', '/' | absolute_url }}" class="disabled current">{{ index }}</a></li>
<li><a href="{{ site.paginate_path | replace: ':num', index | replace: '//', '/' | relative_url }}" class="disabled current">{{ index }}</a></li>
{% else %}
{% comment %} Distance from current page and this link {% endcomment %}
{% assign dist = paginator.page | minus: index %}
{% if dist < 0 %}
{% comment %} Distance must be a positive value {% endcomment %}
{% assign dist = 0 | minus: dist %}
{% endif %}
<li><a href="{{ site.paginate_path | replace: ':num', index | absolute_url }}">{{ index }}</a></li>
<li><a href="{{ site.paginate_path | replace: ':num', index | relative_url }}">{{ index }}</a></li>
{% endif %}
{% endfor %}

Expand All @@ -55,12 +55,12 @@
{% if paginator.page == paginator.total_pages %}
<li><a href="#" class="disabled current">{{ paginator.page }}</a></li>
{% else %}
<li><a href="{{ site.paginate_path | replace: ':num', paginator.total_pages | replace: '//', '/' | absolute_url }}">{{ paginator.total_pages }}</a></li>
<li><a href="{{ site.paginate_path | replace: ':num', paginator.total_pages | replace: '//', '/' | relative_url }}">{{ paginator.total_pages }}</a></li>
{% endif %}

{% comment %} Link next page {% endcomment %}
{% if paginator.next_page %}
<li><a href="{{ site.paginate_path | replace: ':num', paginator.next_page | replace: '//', '/' | absolute_url }}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a></li>
<li><a href="{{ site.paginate_path | replace: ':num', paginator.next_page | replace: '//', '/' | relative_url }}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a></li>
{% else %}
<li><a href="#" class="disabled"><span aria-hidden="true">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</span></a></li>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions _includes/post_pagination.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% if page.previous or page.next %}
<nav class="pagination">
{% if page.previous %}
<a href="{{ page.previous.url | absolute_url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a>
<a href="{{ page.previous.url | relative_url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a>
{% else %}
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a>
{% endif %}
{% if page.next %}
<a href="{{ page.next.url | absolute_url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a>
<a href="{{ page.next.url | relative_url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html }}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a>
{% else %}
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
{% if script contains "://" %}
{% capture script_path %}{{ script }}{% endcapture %}
{% else %}
{% capture script_path %}{{ script | absolute_url }}{% endcapture %}
{% capture script_path %}{{ script | relative_url }}{% endcapture %}
{% endif %}
<script src="{{ script_path }}"></script>
{% endfor %}
{% else %}
<script src="{{ '/assets/js/main.min.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/main.min.js' | relative_url }}"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
{% endif %}

Expand Down
6 changes: 3 additions & 3 deletions _includes/search/lunr-search-scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
{% else %}
{% assign lang = "en" %}
{% endcase %}
<script src="{{ '/assets/js/lunr/lunr.min.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/lunr/lunr-store.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/lunr/lunr-' | append: lang | append: '.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/lunr/lunr.min.js' | relative_url }}"></script>
<script src="{{ '/assets/js/lunr/lunr-store.js' | relative_url }}"></script>
<script src="{{ '/assets/js/lunr/lunr-' | append: lang | append: '.js' | relative_url }}"></script>
2 changes: 1 addition & 1 deletion _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% if s.image contains "://" %}
"{{ s.image }}"
{% else %}
"{{ s.image | absolute_url }}"
"{{ s.image | relative_url }}"
{% endif %}
alt="{% if s.image_alt %}{{ s.image_alt }}{% endif %}">
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/tag-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% for hash in tag_hashes %}
{% assign keyValue = hash | split: '#' %}
{% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
<a href="{{ tag_word | slugify | prepend: path_type | prepend: site.tag_archive.path | absolute_url }}" class="page__taxonomy-item" rel="tag">{{ tag_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
<a href="{{ tag_word | slugify | prepend: path_type | prepend: site.tag_archive.path | relative_url }}" class="page__taxonomy-item" rel="tag">{{ tag_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
{% endfor %}
</span>
</p>
Expand Down
8 changes: 7 additions & 1 deletion docs/_docs/18-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ permalink: /docs/history/
excerpt: "Change log of enhancements and bug fixes made to the theme."
sidebar:
nav: docs
last_modified_at: 2018-03-14T12:54:07-04:00
last_modified_at: 2018-03-20T11:35:28-04:00
toc: true
---

## Unreleased

### Enhancements

* Add default `theme` and `remote_theme` values to `_config.yml`.

### Bug Fixes

* Replace `absolute_url` filter with `relative_url` where it makes sense (asset/nagivation related paths). [#1588](https://github.com/mmistakes/minimal-mistakes/issues/1588)

## [4.10.1](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.10.1)

### Enhancements
Expand Down

0 comments on commit 8a42842

Please sign in to comment.