版权声明优化
目的:修改文章页底部版权声明内容,实现显示 “本文作者”、“本文地址”、“版权声明” 的内容。
目前 Fluid 版本(v1.8.1)中文章末尾版权声明仅设置显示为:

而看到许多博客文章末尾都有完整的文章信息,例如“本文作者”,“本文地址”,“版权声明”等。
在 Next 等主题中自带文章末尾可以添加“文章链接”,只需要在
_config.yml
中 enable
相应模块即可,效果如下图所示。
而在 Fluid 主题中则需要用户对相应配置文件进行修改。
在网上搜寻方法时发现 七夏浅笑 针对 Fluid 主题修改的版本实现了版权声明处的文章链接显示。因为都是使用 Fluid 主题,所以想着对方应该能够解答自己的疑惑所以通过邮件进行了联系。很快得到了大佬答复:

根据大佬的提示(还贴心地标出代码位置,小姐姐很 nice 了),并结合网上相应对版权声明修改的资料进行了操作。
步骤
- 打开
themes\fluid\layout
中的post.ejs
文件;

- 找到以下内容进行修改;

将红色部分替换为以下代码:
<% if(theme.post.copyright.enable && theme.post.copyright.content && page.copyright !== false) { %><p class="note note-warning"><strong>本文作者: </strong><a href="<%- url_for() %>"><%- theme.about.name || config.author || config.title %></a> <br><strong>本文链接: </strong><a href="<%- full_url_for(page.path) %>"><%- full_url_for(page.path) %></a> <br><strong>版权声明: </strong><%- theme.post.copyright.content %> </p> <% } %>Copy
替换结果:

- 保存文件,cmd
hexo clean
hexo s
查看效果;
实现目标:版权声明处添加“本文链接”并能自动生成文章链接。

- cmd
hexo g -d
部署博客。Bingo!
修改 Tag 颜色
- 根据 官方文档 了解到 Tag 相应的语法;

- 如果要修改 Tag 颜色只需要修改
<p class="note note-warning">
即可。
错误做法
- 修改主题配置文件
config.yml
一开始笔者以为只需要简单的修改主题配置文件
_config.yml
里面版权声明处,但在“本文链接”无法正常生成链接。即使在“本文链接”后面加上代码仍然失败。<a href="<%- full_url_for(page.path) %>"><%- full_url_for(page.path) %></a>Copy

hexo s
hexo g
生成结果如下图:
2. 单纯复制修改主题的代码
前面谈到有位小姐姐修改的 Fluid主题 能实现我的目标,我寻思着直接找她改动的代码不就行了吗。于是直接就把相应位置的代码给 copy 了过来,结果造成了页面错误。

最后进行修改调试,才恢复正常。