Hexo Built-in Tag Plugins (Hexo內置標籤外掛)
Tag plugins are different from post tags. They are ported from Octopress and provide a useful way for you to quickly add specific content to your posts.
Block Quote
Perfect for adding quotes to your post, with optional author, source and title information.
Alias: quote
1 | {% blockquote [author[, source]] [link] [source_link_title] %} |
Examples
No arguments. Plain blockquote.
1 | {% blockquote %} |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit lacus ut purus iaculis feugiat. Sed nec tempor elit, quis aliquam neque. Curabitur sed diam eget dolor fermentum semper at eu lorem.
Quote from a book
1 | {% blockquote David Levithan, Wide Awake %} |
Do not just seek happiness for yourself. Seek happiness for all. Through kindness. Through mercy.
Quote from Twitter
1 | {% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %} |
NEW: DevDocs now comes with syntax highlighting. http://devdocs.io
Quote from an article on the web
1 | {% blockquote Seth Godin http://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} |
Every interaction is both precious and an opportunity to delight.
Code Block
Useful feature for adding code snippets to your post.
Alias: code
1 | {% codeblock [title] [lang:language] [url] [link text] [additional options] %} |
Specify additional options in option:value
format, e.g. line_number:false first_line:5
.
Extra Options | Description | Default |
---|---|---|
line_number | Show line number | true |
highlight | Enable code highlighting | true |
first_line | Specify the first line number | 1 |
mark | Line highlight specific line(s), each value separated by a comma. Specify number range using a dash Example: mark:1,4-7,10 will mark line 1, 4 to 7 and 10. | |
wrap | Wrap the code block in <table> | true |
Examples
A plain code block
1 | {% codeblock %} |
1 | alert('Hello World!'); |
Specifying the language
1 | {% codeblock lang:objc %} |
1 | [rectangle setX: 10 y: 10 width: 20 height: 20]; |
Adding a caption to the code block
1 | {% codeblock Array.map %} |
1 | array.map(callback[, thisArg]) |
Adding a caption and a URL
1 | {% codeblock _.compact http://underscorejs.org/#compact Underscore.js %} |
1 | _.compact([0, 1, false, 2, '', 3]); |
Backtick Code Block
This is identical to using a code block, but instead uses three backticks to delimit the block.
``` [language] [title] [url] [link text] code snippet ```Pull Quote
To add pull quotes to your posts:
1 | {% pullquote [class] %} |
Left
1 | {% pullquote left %} |
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tempus molestie arcu, et fringilla mauris placerat ac. Nullam luctus bibendum risus. Ut cursus sed ipsum feugiat egestas. Suspendisse elementum, velit eu consequat consequat, augue lorem dapibus libero, eget pulvinar dolor est sit amet nulla. Suspendisse a porta tortor, et posuere mi. Pellentesque ultricies, mi quis volutpat malesuada, erat felis vulputate nisl, ac congue ante tortor ut ante. Proin aliquam sem vel mauris tincidunt, eget scelerisque tortor euismod. Nulla tincidunt enim nec commodo dictum. Mauris id sapien et orci gravida luctus id ut dui. In vel vulputate odio. Duis vel turpis molestie, scelerisque enim eu, lobortis eros. Cras at ipsum gravida, sagittis ante vel, viverra tellus. Nunc mauris turpis, elementum ullamcorper nisl pretium, ultrices cursus justo. Mauris porttitor commodo eros, ac ornare orci interdum in. Cras fermentum cursus leo sed mattis. In dignissim lorem sem, sit amet elementum mauris venenatis ac.
Right
1 | {% pullquote right %} |
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ligula justo, lobortis sit amet semper vel, dignissim sit amet libero. Praesent ac tempus ligula. Maecenas at gravida odio. Etiam tristique volutpat lacus eu faucibus. Donec non tempus arcu. Phasellus adipiscing, mauris nec mollis egestas, ipsum nunc auctor velit, et rhoncus lorem ipsum at ante. Praesent et sem in velit volutpat auctor. Duis vel mauris nulla. Maecenas mattis interdum ante, quis sagittis nibh cursus et. Nulla facilisi. Morbi convallis gravida tortor, ut fermentum enim gravida et. Nunc vel dictum nisl, non ultrices libero. Proin vestibulum felis eget orci consectetur lobortis. Vestibulum augue nulla, iaculis vitae augue vehicula, dignissim ultrices libero. Sed imperdiet urna et quam ultrices tincidunt nec ac magna. Etiam vel pharetra elit.
jsFiddle
To embed a jsFiddle snippet:
1 | {% jsfiddle shorttag [tabs] [skin] [width] [height] %} |
1 | {% jsfiddle ccWP7 %} |
Gist
To embed a Gist snippet:
1 | {% gist gist_id [filename] %} |
1 | {% gist 996818 %} |
iframe
To embed an iframe:
1 | {% iframe url [width] [height] %} |
1 | {% iframe 'https://butterfly.js.org/' 100% 300px %} |
Image
Inserts an image with specified size.
1 | {% img [class names] /path/to/image [width] [height] '"title text" "alt text"' %} |
Link
Inserts a link with target="_blank"
attribute.
1 | {% link text url [external] [title] %} |
Include Code
Inserts code snippets in source/downloads/code
folder. The folder location can be specified through the code_dir
option in the config.
1 | {% include_code [title] [lang:language] [from:line] [to:line] path/to/file %} |
Examples
Embed the whole content of test.js
1 | {% include_code lang:javascript test.js %} |
Embed line 3 only
1 | {% include_code lang:javascript from:3 to:3 test.js %} |
Embed line 5 to 8
1 | {% include_code lang:javascript from:5 to:8 test.js %} |
Embed line 5 to the end of file
1 | {% include_code lang:javascript from:5 test.js %} |
Embed line 1 to 8
1 | {% include_code lang:javascript to:8 test.js %} |
YouTube
Inserts a YouTube video.
1 | {% youtube video_id %} |
Vimeo
Inserts a responsive or specified size Vimeo video.
1 | {% vimeo video_id [width] [height] %} |
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: {% 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. Using post_path
inside Markdown syntax []()
is not supported.
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.
{% post_link 標籤外掛-Tag-Plugins %}
Display custom text.
{% post_link 標籤外掛-Tag-Plugins 'Link to a post' %}
Escape title.
1 | {% post_link 標籤外掛-Tag-Plugins 'How to use <b> tag in title' %} |
Do not escape title.
1 | {% post_link 標籤外掛-Tag-Plugins '<b>bold</b> custom title' false %} |
Include Assets
Include post assets.
1 | {% asset_path filename %} |
Raw
If certain content is causing processing issues in your posts, wrap it with the raw
tag to avoid rendering errors.
1 | {% raw %} |