0

I am attempting to provide links in my Jekyll _posts that do not follow the https protocol. Currently when clicking on the links provided in my posts https:// is added to all URLs and this is causing protocol errors with any links not following the https protocol.

Here is how I am currently adding my _posts links to my website:

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

I have read that the browser will always use whatever the current protocol is and adding // to the front of any link should fix this. I attempted to add // to the link in the post itself, and directly to the html as shown above, neither of these fixes have worked for me.

David Jacquel
  • 51,670
  • 6
  • 121
  • 147

1 Answers1

0

The protocol less url (//:example.com) was supposed to enforce https for pages resources (css, js, img, ...), depending on the protocol used to serve the main document.

This was a transitional trick and it's not state of the art anymore.

Now, for a lot of good reasons, any http transfer must be done over https. Privacy and integrity are our main concerns here.

If you want to make a link to an external site from a website front matter, it's up to you to :

  • link to an http page : NOT SECURED FOR USER
  • choose to only link to secured https pages : A LITTLE MORE SECURE

So, definitely, you front matter variable must look like

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

And your liquid code :

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

Note the noopener noreferrer.

David Jacquel
  • 51,670
  • 6
  • 121
  • 147