1

Is it possible to set a permalink to an external site within YAML front matter? I am currently using Jekyll, and I am not finding any information using my Google-Fu.

---
layout: full-width
title: TEST
permalink: https://somethingexternal.example
---

Can permalink break out of it's context and head to somethingexternal? I just want the TEST link to appear on the home page, but when clicked, to go to somethingexternal.example.

[edit]: What happens is that it prepends the webroot to the site, which is the expected behavior. So it ends up like:

mysite.blah/https://somethingexternal...

I just need to break out of it, so that it only goes to the external site. I don't know if permalink can do that, though.

marcanuy
  • 23,118
  • 9
  • 64
  • 113
Kahn
  • 149
  • 1
  • 10
  • Is the example you are giving not working and if so, what's the error? – flyx Jun 22 '17 at 12:41
  • When googling, did you find [this article](https://robots.thoughtbot.com/external-posts-in-jekyll)? – flyx Jun 22 '17 at 12:44

1 Answers1

2

Using permalinks for an external link won't work, permalinks aren't for that.

What you are looking for is to define a custom URL in front matter and then access it's value from the page like this:

---
othersite: http://example.com
---

<a href="{{page.othersite}}">visit other site</a>
marcanuy
  • 23,118
  • 9
  • 64
  • 113