Skip to content

Instantly share code, notes, and snippets.

@brandonstephens
Last active February 23, 2017 05:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonstephens/fcfc1255f3b9483eada4 to your computer and use it in GitHub Desktop.
Save brandonstephens/fcfc1255f3b9483eada4 to your computer and use it in GitHub Desktop.
{% assign url_split = page.url | replace_first: "/" | split:"/" %}
{% assign url_size = url_split.size %}
<ol class="breadcrumb">
{% if url_size < 1 %}
<li class="active">Home</li>
{% else %}
<li><a href="/">Home</a></li>
{% endif %}
{% for item in url_split %}
{% if forloop.index == forloop.length %}
<li class="active">{{ page.title }}</li>
{% else %}
{% assign temp_index = forloop.index | minus: 1 %}
<li><a href="/{% for i in (0..temp_index) %}{{ url_split[i] | append: "/" }}{% endfor %}">{{ item | capitalize }}</a></li>
{% endif %}
{% endfor %}
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment