Markdown Syntax
Markdown Syntax
Include Posts
Include links to other posts.
1 | {% post_path filename %} |
You can ignore permalink and folder information, like languages and dates, when using this tag.
For instance:
1 | {% post_link how-to-bake-a-cake %} |
This will work as long as the filename of the post is how-to-bake-a-cake.md, even if the post is located at source/posts/2015-02-my-family-holiday and has permalink 2018/en/how-to-bake-a-cake.
You can customize the text to display, instead of displaying the post’s title.
Post’s title and custom text are escaped by default. You can use the escape option to disable escaping.
For instance:
Display title of the post.
1 | {% post_link hexo-3-8-released %} |
Display custom text.
1 | {% post_link hexo-3-8-released 'Link to a post' %} |
Escape title.
1 | {{% post_link hexo-4-released 'How to use <b> tag in title' %}} |
<b>
会直接显示出来。
Do not escape title.
1 | {% post_link hexo-4-released '<b>bold</b> custom title' false %} |
bold这个单词会加粗。
链接到文章内的标题
1 | [要显示的内容](#标题的名字) |
注意:小括号中#后的标题的名字,不能用大写字母、空格和英文的句点,但问号和顿号可以。大写要改成小写,空格和句点改成短横杠。
中文的麻烦一些,处理方式如下,其中<a>
可以是<div>
、<span>
、<p>
等:
1 | ## <a id="section1">第一章</a> |
Escape Content
Hexo uses Nunjucks to render posts (Swig was used in older version, which share a similar syntax). Content wrapped with{{ }}
or{% %}
will get parsed and may cause problems. You can skip the parsing by wrapping it with the raw tag plugin, single backtick `{{ }}`
or triple backtick.
Alternatively, Nunjucks tags can be disabled through the renderer’s option (if supported), API or front-matter.
1 | {% raw %} |
1 | ``` |
常用的转义如下:
1 | ! ! — 惊叹号 Exclamation mark |