最近,我给了一个网站的重新开发.重新设计的站点将在Markdown中完成,并通过Hugo静态站点生成器运行.
有没有办法在通过Hugo处理的Markdown网页中包含其他文件?如果是这样,怎么样?除非我错过了什么,否则Hugo文档中没有解决这个问题.
使用HTML和一些服务器(至少是Apache),您可以执行以下操作:
<html>
<body>
Some content
<!--#include virtual="name_of_first_file_to_include" -->
More content
<!--#include virtual="name_of_second_file_to_include" -->
Still more content
</body>
<html>
Run Code Online (Sandbox Code Playgroud)
我已经尝试创建一个模板页面,将"Some content"和"More content"等内容放入模板中,然后在我的.md文件中包含的内容通过模板中的{{.Content}}"包含".但是,1)这似乎是使用模板的错误方法.2)如果我需要,我还没想办法引入更多文件.
bep*_*bep 11
对于内容文件,有两种选择:
mmark与它的降价渲染引擎include功能.将内容文件重命名为"*.mmark".请参阅https://github.com/miekg/mmark我是雨果的维护者.
我有一个自定义的简码,用于通过markdown将静态演示文件呈现为代码,这很简单:
layouts / shortcodes / code.html
{{ $file := .Get "file" | readFile }}
{{ $lang := .Get "language" }}
{{ (print "```" $lang "\n" $file "\n```") | markdownify }}
Run Code Online (Sandbox Code Playgroud)
内容/帖子/some-post.md
{{% code file="/static/some-script.js" language="js" %}}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4684 次 |
| 最近记录: |