简体   繁体   English

如何在Jekyll中使原始相对降价链接有效

[英]What does it take to make vanilla relative markdown links work in Jekyll

I'm building a simple Jekyll site. 我正在建立一个简单的Jekyll网站。 I've got a collection of markdown files I've already written. 我已经收集了一些Markdown文件。 When I write I use MacDown because I get to see the images in the preview as I edit (which is great). 当我写的时候,我使用MacDown是因为我在编辑时可以在预览中看到图像(很棒)。

Now that I'm porting them to Jekyll (adding frontmatter and whatnot), I've run into a more that slightly annoying problem with vanilla Jekyll. 现在,我将它们移植到Jekyll(添加了前题和诸如此类的东西)之后,我遇到了香草Jekyll一个稍微有点烦人的问题。 All of my pages have their assets stored with them. 我所有的页面都存储有其资产。 That way, in the markdown I can just link an image like so: 这样,在降价促销中,我可以像这样链接图像:

![Image about git](git.jpg)

I opted to keep this organization within Jekyll because the folders and their contents are copied over to _site on build as is (I'm not using the _posts directory for these pages). 我之所以选择将该组织保留在Jekyll内,是因为文件夹及其内容按_site复制到了_site上的_site (我未在这些页面上使用_posts目录)。 However, the markdown renderer seems to dislike these kinds of links. 但是,降价渲染器似乎不喜欢这些类型的链接。 According to everything I've read , Jekyll doesn't bother translating the markdown for links like this. 根据 读过的 所有 内容 ,Jekyll不会为这样的链接翻译markdown。

My question is: what combination of Jekyll and Kramdown plugins/tricks/hacks do I have to use to make these links work? 我的问题是:我必须使用Jekyll和Kramdown插件/技巧/黑客的什么组合才能使这些链接起作用?

I'd really love to be able to edit in MacDown (or any side-by-side) editor and see my changes before publishing without just hoping the ugly liquid {{ garbage }} will render correctly when I'm done writing. 我真的很希望能够在MacDown(或任何并排)编辑器中进行编辑,并在发布之前查看我的更改,而不必希望完成编写后难看的{{垃圾}}能够正确呈现。 I'd also love for my site not to grow a cancerous and unnecessary img/ folder as I add more content. 我也希望我的网站在添加更多内容时不要增加癌变和不必要的img/文件夹。

EDIT: 编辑:

Although my question is now answered, I was not actually asking a "what plugin do I need to download" question. 尽管现在已经回答了我的问题,但我实际上并不是在问“我需要下载什么插件”问题。 My initial guess was that I'd have to extend the markdown parser myself with my own plugin, which is a programming question. 我最初的猜测是我必须使用自己的插件扩展markdown解析器,这是一个编程问题。

There is a plugin that will allow you to do exactly what you're asking ( ![Image about git](git.jpg) ). 有一个插件可以让您完全按照自己的要求进行操作( ![Image about git](git.jpg) )。 Although because it is a plugin you can't use it on GitHub pages. 尽管因为它是一个插件,所以您不能在GitHub页面上使用它。

It is called jekyll-postfiles plugin by Nicolas Hoizey. Nicolas Hoizey将其称为jekyll-postfiles插件 He wrote an article explaining how it works that might also be helpful. 他写了一篇文章解释它如何工作 ,这也可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM