【问题标题】:Removing https:// protocol from Jekyll Posts从 Jekyll 帖子中删除 https:// 协议
【发布时间】:2019-05-29 11:18:44
【问题描述】:

我试图在我的 Jekyll _posts 中提供不遵循 https 协议的链接。目前,当单击我的帖子中提供的链接时,https:// 会添加到所有 URL,这会导致任何不遵循 https 协议的链接出现协议错误。

这是我目前将 _posts 链接添加到我的网站的方式:

{% if post.website %}
  <li>View Website at:
    <strong>
      <a href="//{{ post.website }}" target=_blank>{{ post.websitename }}</a>
    </strong>
  </li>
{% endif %}

我已经读到浏览器将始终使用当前协议是什么,并且将// 添加到任何链接的前面应该可以解决这个问题。我尝试将 // 添加到帖子本身的链接中,并直接添加到 html 中,如上所示,这些修复都没有为我工作。

【问题讨论】:

    标签: html jekyll liquid


    【解决方案1】:

    协议较少的 url (//:example.com) 应该对页面资源(css、js、img、...)强制执行 https,具体取决于用于提供主文档的协议。

    这是一个过渡技巧,it's not state of the art anymore

    现在,出于很多充分的理由,任何http 的转移都必须通过https 完成。 Privacy and integrity are our main concerns here.

    如果您想从网站前端链接到外部网站,则由您决定:

    • 链接到http 页面:不为用户保密
    • 选择链接到安全的https 页面:更安全

    所以,当然,你的前端变量必须看起来像

    ---
    title: My great title
    website: https://example.com
    ---
    

    还有你的液体代码:

    <a href="{{ post.website }}" target="_blank" rel="noopener noreferrer">{{ post.websitename }}</a>
    

    注意noopener noreferrer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-11
      • 2018-06-02
      • 1970-01-01
      • 2023-03-20
      • 2011-02-06
      • 1970-01-01
      • 2015-10-01
      • 1970-01-01
      相关资源
      最近更新 更多