GitHub+Hexo博客网站搭建(二)
图片无法正常加载
Hexo网页无法正常加载图片
解决方法:
_config.yml和主题的_config.theme.yml里的post_asset_folder
设置为true(这样每篇文章都会有对应同名的文件夹,图片就放在这里面)
npm install https://github.com/CodeFalling/hexo-asset-image --save
(一定要有前面的网址,不能只有hexo-asset-image,这是个坑,害我搞了好久)(因为默认hexo-asset-image下载的插件是有问题的,原因可能是这个插件是好几年前写的,适用于当时的hexo版本,现在hexo版本更新了就不再适用了)
markdown正常插入图片(即
)
图片无法居中
hexo网页的图片总是左对齐,无法居中
解决方法:
- 使用HTML标签,注意该段代码不能放在代码栏中,成功时代码不显示,显示的是图片
1 2 3
| <div align="center"> <img src="图片的绝对路径或与本文档的相对路径" title="鼠标移动到图片上显示该内容"></img> </div>
|
公式无法正常加载
Hexo网页无法正常加载公式
解决方法:
在theme文件夹里找到主题的配置文件_config.yml
把mathjax
下面的enable
设置为 true(到这里只解决了行间公式,即$fomula$
)
在有数学公式的markdown文件里的front-matter(即最开头那块)里加上mathjax: true
(到这里才更进一步解决了公式块,即$$fomula$$
)
文章标题下方显示最后更新时间
在themes\fluid\layout_partials\post\meta-top.ejs文件中的最后一行之前加上代码
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
| <% if (page.meta !== false) { %> <!-- ... --> <!-- 添加span块 --> <span class="myupdated"> <% if (theme.post.updated && compare_date(page.date, page.updated)) { %> <i class="fa fa-repeat" aria-hidden="true" style="margin-right: 0.3rem;"></i> <span class="post-meta "> <% if (theme.post.updated.relative) { %> <% if (theme.post.updated.content) { %> <!-- compatible with older versions--> <%- theme.post.updated.content %><%- relative_date(page.updated, theme.post.updated.date_format) %> <% } else { %> <%- __('post.updated', relative_date(page.updated, theme.post.updated.date_format)) %> <% } %> <% } else { %> <% if (theme.post.updated.content) { %> <!-- compatible with older versions--> <%- theme.post.updated.content %><%- date(page.updated, theme.post.updated.date_format) %> <% } else { %> <%- __('post.updated', date(page.updated, theme.post.updated.date_format)) %> <% } %> <% } %> </span> <% } %> </span> <% } %>
|