Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cloud-Awesome/35e4b4415c84c5712a669ec30fc85d0c to your computer and use it in GitHub Desktop.
Save Cloud-Awesome/35e4b4415c84c5712a669ec30fc85d0c to your computer and use it in GitHub Desktop.
{% assign stop = false %}
{% assign next_url = "" %}
{% comment %}
Loop through all siblings of the current page (i.e. this page's parent's children)
Unfortunately, I haven't found any other liquid object that allows us to get "next sibling" ;)
{% endcomment %}
{% for child in sitemap.current.parent.children %}
{% comment %} If, in the last itteration, it found the current page, this is the next page, set URL and exit {% endcomment %}
{% if stop == true %}
{% assign next_url = child.url %}
{% break %}
{% endif %}
{% comment %} If this sibling is the current page, the next one will be the one we want {% endcomment %}
{% if child.url == page.url %}
{% assign stop = true %}
{% endif %}
{% endfor %}
{% comment %} Use URL of next sibling page, appending any URL parameters (e.g. ?id=xxx) {% endcomment %}
<a id="anon-submit" href="{{ next_url }}{{ request.query }}" class="submit-btn btn btn-primary form-action-container-left">Continue</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment