Jekyll Internal Post Links
This is a pretty niche problem, but... I run a blog that runs on Jekyll and I post very regularly. To keep my editing sane I regularly archive posts, and those archived posts get a pretty strict structure. But, I go a full year before archiving.
Where this hurts is in links to other posts. I used to be able to absolutely reference the file name (per jekyll markdown internal links), but this appears to be being deprecated:
Deprecation: A call to '% post_url 2018-09-06-peppermint %' did not match a post using the new matching method of checking name (path-date-slug) equality. Please make sure that you change this tag to match the post's name exactly.
Now, if I have to include the full path to the file, then when I archive my posts for the year I have to parse all of the posts for the entire year and update any links between them to include the new file path for their archived location, defeating the point of using this tool at all. A direct link to the page would actually be better, given that I change my URL structure less often.
Is there a better solution for internal links that doesn't depend on the file structure, allowing a file to be moved without having to update every link to that file?
Example File structure:
_posts
-2018
-post1
-post2
-etc
-Archive
-2017
-2016
If there's no better answer, I may just have to go back to using absolute external links.
jekyll
add a comment |
This is a pretty niche problem, but... I run a blog that runs on Jekyll and I post very regularly. To keep my editing sane I regularly archive posts, and those archived posts get a pretty strict structure. But, I go a full year before archiving.
Where this hurts is in links to other posts. I used to be able to absolutely reference the file name (per jekyll markdown internal links), but this appears to be being deprecated:
Deprecation: A call to '% post_url 2018-09-06-peppermint %' did not match a post using the new matching method of checking name (path-date-slug) equality. Please make sure that you change this tag to match the post's name exactly.
Now, if I have to include the full path to the file, then when I archive my posts for the year I have to parse all of the posts for the entire year and update any links between them to include the new file path for their archived location, defeating the point of using this tool at all. A direct link to the page would actually be better, given that I change my URL structure less often.
Is there a better solution for internal links that doesn't depend on the file structure, allowing a file to be moved without having to update every link to that file?
Example File structure:
_posts
-2018
-post1
-post2
-etc
-Archive
-2017
-2016
If there's no better answer, I may just have to go back to using absolute external links.
jekyll
it looks like you are right - I don't use post_url but it was my understanding that it worked as you have been using it. Now it looks like it wants the correct path no matter what (I don't think it is deprecated, just new behavior - wants full path?). There is alsolink
which does much the same thing, but it looks like it wants the path too.
– Ron
Nov 17 '18 at 7:02
Needing the path is actually more likely to change for me though, as I adjust my archiving. The path is likely to change, but the link structure is not. If the path is required... it's actually easier for me to do absolute URLs given that those are weirdly less likely to change..
– David Scott IV
Nov 18 '18 at 9:01
add a comment |
This is a pretty niche problem, but... I run a blog that runs on Jekyll and I post very regularly. To keep my editing sane I regularly archive posts, and those archived posts get a pretty strict structure. But, I go a full year before archiving.
Where this hurts is in links to other posts. I used to be able to absolutely reference the file name (per jekyll markdown internal links), but this appears to be being deprecated:
Deprecation: A call to '% post_url 2018-09-06-peppermint %' did not match a post using the new matching method of checking name (path-date-slug) equality. Please make sure that you change this tag to match the post's name exactly.
Now, if I have to include the full path to the file, then when I archive my posts for the year I have to parse all of the posts for the entire year and update any links between them to include the new file path for their archived location, defeating the point of using this tool at all. A direct link to the page would actually be better, given that I change my URL structure less often.
Is there a better solution for internal links that doesn't depend on the file structure, allowing a file to be moved without having to update every link to that file?
Example File structure:
_posts
-2018
-post1
-post2
-etc
-Archive
-2017
-2016
If there's no better answer, I may just have to go back to using absolute external links.
jekyll
This is a pretty niche problem, but... I run a blog that runs on Jekyll and I post very regularly. To keep my editing sane I regularly archive posts, and those archived posts get a pretty strict structure. But, I go a full year before archiving.
Where this hurts is in links to other posts. I used to be able to absolutely reference the file name (per jekyll markdown internal links), but this appears to be being deprecated:
Deprecation: A call to '% post_url 2018-09-06-peppermint %' did not match a post using the new matching method of checking name (path-date-slug) equality. Please make sure that you change this tag to match the post's name exactly.
Now, if I have to include the full path to the file, then when I archive my posts for the year I have to parse all of the posts for the entire year and update any links between them to include the new file path for their archived location, defeating the point of using this tool at all. A direct link to the page would actually be better, given that I change my URL structure less often.
Is there a better solution for internal links that doesn't depend on the file structure, allowing a file to be moved without having to update every link to that file?
Example File structure:
_posts
-2018
-post1
-post2
-etc
-Archive
-2017
-2016
If there's no better answer, I may just have to go back to using absolute external links.
jekyll
jekyll
asked Nov 15 '18 at 16:13
David Scott IVDavid Scott IV
150212
150212
it looks like you are right - I don't use post_url but it was my understanding that it worked as you have been using it. Now it looks like it wants the correct path no matter what (I don't think it is deprecated, just new behavior - wants full path?). There is alsolink
which does much the same thing, but it looks like it wants the path too.
– Ron
Nov 17 '18 at 7:02
Needing the path is actually more likely to change for me though, as I adjust my archiving. The path is likely to change, but the link structure is not. If the path is required... it's actually easier for me to do absolute URLs given that those are weirdly less likely to change..
– David Scott IV
Nov 18 '18 at 9:01
add a comment |
it looks like you are right - I don't use post_url but it was my understanding that it worked as you have been using it. Now it looks like it wants the correct path no matter what (I don't think it is deprecated, just new behavior - wants full path?). There is alsolink
which does much the same thing, but it looks like it wants the path too.
– Ron
Nov 17 '18 at 7:02
Needing the path is actually more likely to change for me though, as I adjust my archiving. The path is likely to change, but the link structure is not. If the path is required... it's actually easier for me to do absolute URLs given that those are weirdly less likely to change..
– David Scott IV
Nov 18 '18 at 9:01
it looks like you are right - I don't use post_url but it was my understanding that it worked as you have been using it. Now it looks like it wants the correct path no matter what (I don't think it is deprecated, just new behavior - wants full path?). There is also
link
which does much the same thing, but it looks like it wants the path too.– Ron
Nov 17 '18 at 7:02
it looks like you are right - I don't use post_url but it was my understanding that it worked as you have been using it. Now it looks like it wants the correct path no matter what (I don't think it is deprecated, just new behavior - wants full path?). There is also
link
which does much the same thing, but it looks like it wants the path too.– Ron
Nov 17 '18 at 7:02
Needing the path is actually more likely to change for me though, as I adjust my archiving. The path is likely to change, but the link structure is not. If the path is required... it's actually easier for me to do absolute URLs given that those are weirdly less likely to change..
– David Scott IV
Nov 18 '18 at 9:01
Needing the path is actually more likely to change for me though, as I adjust my archiving. The path is likely to change, but the link structure is not. If the path is required... it's actually easier for me to do absolute URLs given that those are weirdly less likely to change..
– David Scott IV
Nov 18 '18 at 9:01
add a comment |
1 Answer
1
active
oldest
votes
Solution 1. Use your own include
Create an post_url.html file and write this:
% include post_url.html slug="2018-09-06-peppermint" %
The include (called post_url.html) should find the post with the right slug and echo the link, like this:
where:'slug',include.slug %
<a href=" link[0].url "> link[0].title </a>
Solution 2. Search and replace
You have to parse posts? A simple search and replace on all files, looking for (/2018/
and replace with (/Archive/2018/
should do the trick (if you use markdown links). This should take just a few seconds.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323570%2fjekyll-internal-post-links%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solution 1. Use your own include
Create an post_url.html file and write this:
% include post_url.html slug="2018-09-06-peppermint" %
The include (called post_url.html) should find the post with the right slug and echo the link, like this:
where:'slug',include.slug %
<a href=" link[0].url "> link[0].title </a>
Solution 2. Search and replace
You have to parse posts? A simple search and replace on all files, looking for (/2018/
and replace with (/Archive/2018/
should do the trick (if you use markdown links). This should take just a few seconds.
add a comment |
Solution 1. Use your own include
Create an post_url.html file and write this:
% include post_url.html slug="2018-09-06-peppermint" %
The include (called post_url.html) should find the post with the right slug and echo the link, like this:
where:'slug',include.slug %
<a href=" link[0].url "> link[0].title </a>
Solution 2. Search and replace
You have to parse posts? A simple search and replace on all files, looking for (/2018/
and replace with (/Archive/2018/
should do the trick (if you use markdown links). This should take just a few seconds.
add a comment |
Solution 1. Use your own include
Create an post_url.html file and write this:
% include post_url.html slug="2018-09-06-peppermint" %
The include (called post_url.html) should find the post with the right slug and echo the link, like this:
where:'slug',include.slug %
<a href=" link[0].url "> link[0].title </a>
Solution 2. Search and replace
You have to parse posts? A simple search and replace on all files, looking for (/2018/
and replace with (/Archive/2018/
should do the trick (if you use markdown links). This should take just a few seconds.
Solution 1. Use your own include
Create an post_url.html file and write this:
% include post_url.html slug="2018-09-06-peppermint" %
The include (called post_url.html) should find the post with the right slug and echo the link, like this:
where:'slug',include.slug %
<a href=" link[0].url "> link[0].title </a>
Solution 2. Search and replace
You have to parse posts? A simple search and replace on all files, looking for (/2018/
and replace with (/Archive/2018/
should do the trick (if you use markdown links). This should take just a few seconds.
answered Nov 19 '18 at 8:21
JoostSJoostS
6,21121739
6,21121739
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323570%2fjekyll-internal-post-links%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
it looks like you are right - I don't use post_url but it was my understanding that it worked as you have been using it. Now it looks like it wants the correct path no matter what (I don't think it is deprecated, just new behavior - wants full path?). There is also
link
which does much the same thing, but it looks like it wants the path too.– Ron
Nov 17 '18 at 7:02
Needing the path is actually more likely to change for me though, as I adjust my archiving. The path is likely to change, but the link structure is not. If the path is required... it's actually easier for me to do absolute URLs given that those are weirdly less likely to change..
– David Scott IV
Nov 18 '18 at 9:01