我希望能够定义一个HTML模板,这是打印优化。看起来Hugo自定义输出格式正是我所需要的,但我正在努力理解如何让它工作。
以下是定义新格式的config.yaml文件的摘录:
outputFormats:
printFormat:
name: print
mediaType: text/html
isHTML: true
path: print
outputs:
page:
- HTML
- print
home:
- HTML
- RSS
section:
- HTML
- RSS
taxonomy:
- HTML
- RSS
term:
- HTML
- RSS我还创建了<theme>/layouts/_default/baseof.print.html和<theme>/layouts/_default/single.print.html。
当我尝试构建时,我没有得到任何错误,但是我也没有看到生成的任何打印模板。
我也不完全理解针对资源的url结构是什么样子。以下是我尝试过的方法
https://<domain-name>/posts/<post-name>.print
https://<domain-name>/posts/<post-name>.print.html
https://<domain-name>/posts/print/<post-name>
https://<domain-name>/posts/<post-name>/print/index.html有人能帮助我了解我在配置中做错了什么,以及访问自定义输出的URL看起来是什么样子?
发布于 2020-08-24 14:20:37
我解决了这个问题。以下是使其工作的config.yaml的更改...
outputFormats:
printFormat:
name: print
mediaType: text/html
baseName: print
isPlainText: false
rel: alternate
isHTML: false
noUgly: true
permalinkable: false做了这样的更改后,下面的url将使我能够访问“打印机友好”模板:
https://<domain-name>/posts/<post-name>/print.htmlhttps://stackoverflow.com/questions/63555379
复制相似问题