我刚刚开始使用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 %}
这可能吗?还有其他方法解决这个问题吗?
答案 0 :(得分:36)
page.url
是当前页面的网址,没有主机(例如/index.html
),如Page Variables中所述。所以,在这种情况下:
{% if page.url == "/index.html" %}
something
{% else %}
other thing
{% endif %}
(但是,我认为你不再需要这个,你的另一个问题可能已经解决了。:))