Reputation: 24061
How can I get the current page's URL?
I have tried:
{{ site.url }}
But this fails to out put anything.
Upvotes: 9
Views: 4712
Reputation: 891
It can work out of the box in GitHub Pages at least using {{ page.url | absolute_url }}
. See Page Variables doc in conjunction with the Absolute URL filter.
Upvotes: 3
Reputation: 1648
You need to define that in your _config.yml
.
It's empty by default.
Once defined you might want something like {{site.url}}{{page.url}}
to get the whole path.
To capture the whole path in a variable you can use
{% capture url_path %}{{site.url}}{{page.url}}{% endcapture %}
Upvotes: 20