【问题标题】:Liquid markup to detect current page URL?检测当前页面 URL 的液体标记?
【发布时间】:2012-04-07 16:27:49
【问题描述】:

我最近才开始使用 Github 来托管我的博客(使用 Jekyll 和 Liquid)。但是,我有an issue which I can't currently fix。如果我能够检测到用户正在访问哪个“页面”或“网址”,则该问题可能会被破解/解决。

类似:

{% if user_is_currently_at_this_url %}
    {{ display something }}
{% else %}
    {{ display something else }}
{% endif %}

这可能吗?有没有其他方法可以解决这个问题?

【问题讨论】:

  • page.url{{ page.url | absolute_url }} 以防你想获取绝对 URL

标签: html url github jekyll liquid


【解决方案1】:

page.url 是当前页面的 URL,没有主机(例如 /index.html),如 Page Variables 中所述。所以,在这种情况下:

{% if page.url == "/index.html" %}
   something
{% else %}
   other thing
{% endif %}

(但是,我认为您不再需要这个了,您的其他问题可能已经解决了。:))

【讨论】:

猜你喜欢
  • 2017-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多