Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick Start
Create a new post
1 | $ hexo new "My New Post" |
More info: Writing
Run server
1 | $ hexo server |
More info: Server
Generate static files
1 | $ hexo generate |
More info: Generating
Deploy to remote sites
1 | $ hexo deploy |
More info: Deployment
How to displace partly article?
add<!-- more -->
in some place,which you want to hide.
How to create a Hexo Blog
1.install Node.js
if you are macos users,you can install by command in Terminal as follows:
1 | brew install node |
However,you should install Homebrew firstly
after these,you can input node -v
to make sure install successful.
Besides,you can input npm -v
to check out installation of npm(Be installed at the same time when install Node.js)
2.change source
Because original source is too slow,so we need to change the source that be in the national location.you can input command sa follows:npm install -g cnpm --registry=http://registry.npm.taobao.org
we change the source to Taobao,you can also check out installation of cnpm by cnpm -v
3.install hexo frame
It’s so easy that yan can only input sentencecnpm install -g hexo-cli
Now,you are already install hexo frame
you can check out by commandhexo -v
4.build blog
Now, we can really build our blog.
first,mkdir blog
create blog catalogue
second,cd blog
enter blog catalogue
Then,sudo hexo init
create blog ,initialize bloghexo s
start local blog servicehttp://localhost:4000/
Go to local access address
5.create new article
hexo n "我的第一篇文章"
create new blog file(.md)cd source/_posts
enten path to modify blog file content
return blog addresshexo clean
clean cachehexo g
create
6.create a github repositories
named’YourGithubName.github.io’
Then cnpm install --save hexo-deployer-git
install git deploying plug-ins in blod cataloguecd blog
to configure config.yml
file
add following code :
1 | # Deployment |
7.deploy to github repositories
hexo d
deploy to your websitehttps://YourGithubName.github.io/
go to this website to check out
you can also change theme ,have a try by yourself
Problems encountered
1.port 4000 has been used
The first method: kill the process,which use port 4000.
The second method:add the following code in
_config.yml
that is in blog catalogue:1
2
3
4server:
port: 4001
compress: true
header: truechange to 4001 port.
solve the problem…
2.添加音乐
- 打开网易云音乐网页版,打开所需要的音乐,复制选择的背景音乐分享外链
- 引入播放器代码
- 在
themes/yilia/layout/_partial/left-col.ejs
文件nav
标签中添加代码。放在
<nav>
和</nav>
之内1
2
3
4
5
6<!-- 网易云音乐插件 -->
<% if (theme.music && theme.music.enable){ %>
<div style="position:absolute; bottom:120px left:auto; width:85%">
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="240" height="52" src="//music.163.com/outchain/player?type=2&id=<%=theme.music.id||1334445174%>&auto=<%=theme.music.autoplay?1:0%>&height=32"></iframe> //这段即音乐外链
</div>
<% } %> - 在yilia主题配置文件中添加属性
1
2
3
4
5# 网易云音乐插件
music:
enable: true
#id: 1332647902 # 网易云分享的ID
autoplay: true # 是否开启自动播放
github的问题
- 2021.9.17 最近很久没有写过博客了,碰巧有点时间想写一写一些关于cmake的知识。可以昨晚在使用hexo时却出现了以下问题,特此记录,并给出解决措施。
问题描述如下:
1 | remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. |
经查找发现,原来是github至2021.8.13日起,停止使用密码进行验证登入了,我之前一直都是使用密码登入的,所以github推荐使用personal access token代替验证登入,而我这里选择使用SSH登入,方法如下。
解决措施
1.在本地获取你主机的SSH公钥,使用以下命令,一直确定即可:
ssh-keygen -t rsa -C "GitHub账号"
2.然后用:cat+公钥路径,把出现的key复制下来
3.在github的SSH and GPG keys中将公钥添加进去即可。
4.记得修改hexo中的_config.yml
文件中的协议,修改为SSH的网址形式。