用Hugo搭建个人博客——显示目录

文章参考了Hugo博客目录放在侧边 修改配置 文章较长时,能够显示可直接跳转的目录是极好的,PaperMod原生就支持目录,只需简单修改配置即可。 在config.yml中,添加或修改params对应的配置为以下内容: 1 2 3 params: ShowToc: true TocOpen: true 目录移至侧边 虽然PaperMod原生就有目录,但是却是在顶部,便捷性几乎为0,放在侧边就会方便许多。 在项目目录layouts/partials下添加toc.html文件,内容如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 {{- $headers := findRE "<h[1-6]....

2024-06-09 21:58:00 · 6 分钟 · 慢步道人

用Hugo搭建个人博客——支持Mermaid

文章参考了Hugo博客添加mermaid作图 文章可以使用Mermaid添加流程图等,来增强信息传递效率和阅读体验,但PaperMod原生似乎并不支持(或者支持得不好?)Mermaid。 修改方法 在项目目录layouts/shortcodes下添加mermaid.html,内容如下: 1 2 3 <div class="mermaid" align="center"> {{.Inner}} </div> 复制主题目录themes/hugo-PaperMod/layouts/partials下的header.html到项目目录layouts/partials,然后在开头插入以下内容: 1 2 3 {{ if (.Params.mermaid) }} <script async src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> {{ end }} 在archetypes/default.md或者对应的模板头里添加以下内容: 1 mermaid: true 使用方法 把Markdown的语法标识替换为用{{}}包换的<mermaid>和</mermaid>标签(由于会直接被识别成shortcode进行解析,只能用语言描述),包括住实际的mermaid代码。 graph LR a-->b-.->c

2024-06-09 17:38:54 · 1 分钟 · 慢步道人

用Hugo搭建个人博客——配置

空空如也的页面,需要好好配置一番才能丰富多彩。 配置config.yml 隐性配置 在上一篇config.yml的基础上先加入以下内容: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 copyright: "© 20xx [xxx](https://github.com/xxx)" # 版权说明 paginate: 5 # 每页文章数 enableInlineShortcodes: true # 是否使用短码 enableRobotsTXT: true # 是否允许被搜索引擎收录 buildDrafts: false buildFuture: false buildExpired: false enableEmoji: true # 是否使用emoji表情 pygmentsUseClasses: true mainsections: ["posts", "papermod"] minify: disableXML: true outputs: home: - HTML - RSS - JSON markup: goldmark: renderer: unsafe: true highlight: noClasses: false codeFences: true guessSyntax: true lineNos: true services: instagram: disableInlineCSS: true twitter: disableInlineCSS: true params: env: production description: "xxx's blog" author: xxx # 作者 defaultTheme: auto ShowShareButtons: false # 是否显示分享按钮 ShowReadingTime: true # 是否显示阅读时间 displayFullLangName: true ShowPostNavLinks: true # 是否显示上一页下一页 ShowBreadCrumbs: true ShowCodeCopyButtons: true # 是否在代码上显示复制按钮 ShowRssButtonInSectionTermList: false ShowAllPagesInArchive: true ShowPageNums: true # 是否显示页数 ShowToc: false # 是否显示目录 DateFormat: "2006-01-02 15:04:05" # 时间格式 socialIcons: - name: github title: View Source on Github url: "https://github....

2024-06-01 20:45:01 · 3 分钟 · 慢步道人