液体标记检测当前页面URL?

n0p*_*0pe 21 html url github liquid jekyll

我刚刚开始使用Github来托管我的博客(使用Jekyll和Liquid).但是,我遇到了一个目前无法解决的问题.如果我能够检测到用户正在访问哪个"页面"或"网址",则该问题可能被黑客攻击/解决.

就像是:

{% if user_is_currently_at_this_url %}
    {{ display something }}
{% else %}
    {{ display something else }}
{% endif %}
Run Code Online (Sandbox Code Playgroud)

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

huo*_*uon 39

page.url页面变量中/index.html记录的当前页面的URL,没有主机(例如).所以,在这种情况下:

{% if page.url == "/index.html" %}
   something
{% else %}
   other thing
{% endif %}
Run Code Online (Sandbox Code Playgroud)

(但是,我认为你不再需要这个,你的另一个问题可能已经解决了.:))

  • 这不适用于github页面上的404重定向:( (3认同)