Hugo

Hugo Shortcode 渲染外部代码和文件

438 words

有时在我的文章中会包含代码块(例如,javascript);一个直接的方法是将代码直接复制到相应的markdown文件中。

然而,由于将来可能会更新这段代码,但仍然希望我的博客文章显示最新的版本。 有时在多篇文章中引用同一个代码块,更新的时候就比较麻烦,需要复制粘贴多次。

Hugo Shortcode 渲染Mermaid图形

572 words

创建Mermaid shortcode

创建shortcodes目录

cd your_theme_dir
mkdir layouts/shortcodes

创建mermaid.html文件

cd shortcodes
touch mermaid.html

shortcode的名字就是mermaid;该文件名与我们要使用的shortcode名称相同。将以下内容粘贴到该文件中。

Add Gitalk for comments in Hugo Blog

354 words

Gitalk is a comment plug based on Github issue api. Hugo can compile the Markdown files with themes and templates into static web files, such as CSS, HTML and JavaScript.

To use Gitalk in the Hugo blog, we need to add Gitalk related code as <div> into the HTML template. Then update the config.toml for Gitalk.