Reputation:
I have a Jekyll site. I have a part of the homepage where content goes. Initially, I created a .md
file in _includes/
. I added {% include myContent.md %}
. This worked.
Then I realized that the Markdown file was nearly identical to my repository's README.md
file. Ideally, I could edit one and they would both change.
I can access my README.md
. (E.g.: https://raw.githubusercontent.com/facebook/react/master/README.md)
Is there an elegant way in which I can include this as part of my site? I tried {% include https://raw.githubusercontent.com/facebook/react/master/README.md %}
. It did not work.
(Sidenote: Where can I get the URL for my repository's social media image? I'd rather not have it uploaded to my site and to GitHub if it can be more elegant.)
Upvotes: 2
Views: 1135
Reputation: 325
There is a plugin called jekyll-remote-include for this.
Once installed:
{% remote_include https://raw.githubusercontent.com/jekyll/jekyll/master/README.markdown %}
Upvotes: 1
Reputation: 1363
Unfortunately, this isn't possible. According to the Jekyll documentation, include
only lets you include
the content from another file stored in the _includes folder
Another option, include_relative
, will let you
include file fragments relative to the current file
You are limited to including relative files in the current directory or lower, higher-level directories aren't able to be included in this manner.
I imagine it's not allowed as a security measure - although I'm not able to come up with a feasible attack vector if they were to allow it.
Upvotes: 1