如何搭建个人免费博客(教你10分钟搭建酷炫的个人博客)
$ npm install -g hexo-cli
$ hexo init <folder>
$ cd <folder>
$ npm install
,今天小编就来说说关于如何搭建个人免费博客?下面更多详细答案一起来看看吧!
如何搭建个人免费博客
以个人博客为例,博客地址(http://wushaobin.top/)准备工作安装
$ npm install -g hexo-cli
$ hexo init <folder>
$ cd <folder>
$ npm install
$ hexo new "My New Post"
$ hexo server
$ hexo s
$ hexo generate
$ hexo g
$ hexo deploy
$ hexo d
详细准备工作,可以查阅hexo官网
安装主题cactus,一个很程序员的主题,推荐!克隆仓库,并且将源文件复制到博客项目中themes目录下
git clone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus
# 首页Projects的url
projects_url: https://github.com/xiaobinwu
# 设置页面方向
direction: ltr
# 首页导航
# $ hexo new page about,可以创建page页面
nav:
home: /
about: /about/
articles: /archives/
categories: /categories/
search: /search/
# 社交链接
social_links:
github: https://github.com/xiaobinwu
mail: mailto:xiaobin_wu@yahoo.com
# 开启标签快捷方式
tags_overview: true
# 首页 Writing的展示条数
posts_overview:
show_all_posts: false
post_count: 5
sort_updated: false
# 排列方式
archive:
sort_updated: false
post:
show_updated: false
# logo设置
logo:
enabled: true
width: 50
height: 50
url: /images/logo.png
gravatar: false
# ico设置
favicon:
desktop:
url: /images/favicon.ico
gravatar: false
android:
url: /images/favicon-192x192.png
gravatar: false
apple:
url: /images/apple-touch-icon.png
gravatar: false
# 高亮语法
highlight: kimbie.dark
# 博客主题色,dark, light, classic, white
colorscheme: dark
page_width: 48
# rss设置
rss: atom.xml
open_graph:
fb_app_id:
fb_admins:
twitter_id:
google_plus:
# disqus评论,默认不开启,需翻墙
disqus:
enabled: false
shortname: cactus-1
# 谷歌统计
google_analytics:
enabled: false
id: UA-86660611-1
# 百度统计
baidu_analytics:
enabled: false
id: 2e6da3c375c8a87f5b664cea6d4cb29c
gravatar:
email: xiaobin_wu@yahoo.com
valine:
enable: true
app_id: xxxxxx
app_key: xxxxxxx
valine:
enable: true
app_id: xxxx
app_key: xxxx
<% if(theme.valine.enable) { %>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script>
<div id="vcomments" class="blog-post-comments"></div>
<script>
new Valine({
el: '#vcomments',
visitor: true,
appId: '<%=theme.valine.app_id %>',
appKey: '<%=theme.valine.app_key %>',
placeholder: 'ヾノ≧∀≦)o来啊,快活啊!',
avatar: 'robohash'
})
</script>
<% } %>
mkdir blog.git && cd blog.git
git init --bare
deploy:
type: git
message: update
repo: root@xx.xxx.xx.xxx:/www/wwwroot/blog.git,master
npm install hexo-deployer-git --save
cd /www/wwwroot/blog.git/hooks
touch post-receive
vim post-receive
#!/bin/bash -l
GIT_REPO=/www/wwwroot/blog.git
TMP_GIT_CLONE=/www/wwwroot/tmp/blog
PUBLIC_WWW=/www/wwwroot/blog
rm -rf ${TMP_GIT_CLONE}
mkdir ${TMP_GIT_CLONE}
git clone $GIT_REPO $TMP_GIT_CLONE
rm -rf ${PUBLIC_WWW}/*
cp -rf ${TMP_GIT_CLONE}/* ${PUBLIC_WWW}
chmod x post-receive
chmod 777 -R /www/wwwroot/blog
chmod 777 -R /www/wwwroot/tmp/blog
$ hexo g -d
免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com