Hexo: 资源文件夹到底怎么使用阿?

Created on 1 Dec 2016  ·  7Comments  ·  Source: hexojs/hexo

{% asset_path slug %}
{% asset_img slug [title] %}
{% asset_link slug [title] %}

具体应该怎么使用呢?哪个是固定的?哪些是路径?

Most helpful comment

文章中我希望有一个PDF文件,希望提供给读者下载。pdf文件应该放在哪里。怎么来引用这个pdf文件。

All 7 comments

比如你有个图片叫img.jpg,在markdown文档可以写成:

{% asset_img img.jpg "img test" %}

如果要在render模版里面用资源文件夹中的文件,该怎么引用呢?

@vicvinc 模板中可以使用url_for

我这样理解的对不对,比如,在post的markdown里面定义了

---
title: post
cover:  '/cover.png'
----

然后在render里面这样使用对不对:

<div class="cover" style="background: url({{ url_for(post.cover) }}) center / cover no-repeat">
</div>

BTW,多谢回复啦,作者幸苦

@vicvinc 如果在配置中relative: true,那么你的写法是对的。
Hexo是众人努力的开源项目,喜欢用就好。 😄

文章中我希望有一个PDF文件,希望提供给读者下载。pdf文件应该放在哪里。怎么来引用这个pdf文件。

同问楼上的问题

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JackieLuo picture JackieLuo  ·  45Comments

dsaltares picture dsaltares  ·  46Comments

icepy picture icepy  ·  34Comments

fabien-h picture fabien-h  ·  22Comments

SukkaW picture SukkaW  ·  22Comments