npm install -g cnpm --registry=http://registry.npm.taobao.org
cnpm -v //查看安装版本
cnpm install -g hexo-cli
hexo -v //查看hexo版本
在 blog 文件夹中打开 Git Bash,输入
hexo init //新建一个网站
hexo server
打开浏览器中,输入 http://localhost:4000 访问博客
ctrl+c 关闭服务器
hexo new "第一篇博客"
hexo clean
建议每次生成站点或部署之前都用该命令清理一下缓存
hexo generate
hexo server
在刚才打开的浏览器博客页面刷新,出现新写的文章
cnpm install --save hexo-deployer-git
type: git
repo: git@github.com:basssss/basssss.github.io.git(仓库地址)
branch: master
hexo deploy
至此hexo框架搭建静态博客完毕
参考资料
git clone https://github.com/Shen-Yu/hexo-theme-ayer.git themes/ayer
打开_config.yml文件,找到theme修改为ayer保存退出。
仿照分类和标签的方式,新增menu如"关于我"
hexo new page AboutMe
至此ayer主题安装完毕
参考资料(作者文档中的安装步骤写的很详细,看文档就好)
ayer主题默认在主页和文章底部添加Gitalk,在自己新增的页面如友情链接link页面中安装Gitalk需要修改代码
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<div id="gitalk-container"></div>
var gitalk = new Gitalk({
clientID: 'GitHub Application Client ID',
clientSecret: 'GitHub Application Client Secret',
repo: 'GitHub repo',
owner: 'GitHub repo owner',
admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'],
id: location.pathname, // Ensure uniqueness and length less than 50
distractionFreeMode: false // Facebook-like distraction free mode
})
gitalk.render('gitalk-container')
至此Gitalk评论插件安装完毕
参考资料:Gitalk
原主题是没有友链页面的,需要自己写代码,这是我的
在D:\blog\source\links下新建文件夹LinkImage存放图片,新建文件link.css
<body>
<ul class="allLinks">
<li>
<img src="图片地址" alt="图片描述">
<a href="友情链接地址">博客名</a>
</li>
</ul>
</body>
.allLinks {
display: -webkit-flex; /* Safari */
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.allLinks li {
list-style: none;
display: inline-flex;
border-radius: 1rem;
width: 20rem;
height: 8rem;
margin-top: 3rem;
margin-right:2rem;
overflow: hidden; /*超出边界部分隐藏*/
background-color: #403e3e;
}
.allLinks li img {
width:6rem;
height:6rem;
border-radius: 50%;
margin: 1rem;
}
.allLinks li a {
width: 12rem;
padding-top: 10%;
text-align: center;
cursor: pointer;
text-decoration: none;
font-size: 1.7rem;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", 微软雅黑, Arial, sans-serif;
color:#bbb;
word-wrap: break-word; /*文字换行*/
}
type: "categories"
layout: "categories"
categories:
- 分类名
type: "tags"
layout: "tags"
tags:
- 标签名
修改D:\blog\themes\ayer\layout_partial\ayer.ejs的代码,将原来的a标签修改为在Github ribbon中选中样式的代码,并修改所有的"github-corner"为"forkMe"
{% asset_img 六GithubRibbon.JPG GithubRibbon %}
在写的博客中插入图片时,不能用普通的Markdown语法,参考hexo文档,应该:
npm install https://github.com/CodeFalling/hexo-asset-image -- save
hexo new [layout] <title>
{% asset_img 图片名.jpg 描述语句 %}
hexo默认文章路径为年/月/日/文件名,目录层次过长不利于收录,所以在根目录的config.yml文件中,修改默认路径
permalink: :year/:month/:day/:title/
为
permalink: archives/:title.html