Skip to content

Instantly share code, notes, and snippets.

@adamhollett
Created April 7, 2016 15:00
Show Gist options
  • Save adamhollett/ec460f0f252184135a8698c95d5202a1 to your computer and use it in GitHub Desktop.
Save adamhollett/ec460f0f252184135a8698c95d5202a1 to your computer and use it in GitHub Desktop.
Remove the final folder from a URL with pure Liquid
{% assign url = "foo.com/bar/baz/baz/" | split: "/" | reverse | join: "/" | replace_first: "/", "|" | split: "|" | last | split: "/" | reverse | join: "/" %}
{{ url }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment