如何搭建博客?它有什么好处(教你10分钟搭建酷炫的个人博客)
三石哥
2022-07-16 17:42:35
297
准备工作
安装
$ npminstall -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目录下
gitclone https://github.com/probberechts/hexo-theme-cactus.git themes/cactus
themes/cactus/_config.yml相关配置,详细解释可以看官方文档
# 首页Projects的urlprojects_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/xiaobinwumail:mailto:xiaobin_wu@yahoo.com# 开启标签快捷方式tags_overview:true# 首页 Writing的展示条数posts_overview:show_all_posts:falsepost_count:5sort_updated:false# 排列方式archive:sort_updated:falsepost:show_updated:false# logo设置logo:enabled:truewidth:50height:50url:/images/logo.pnggravatar:false# ico设置favicon:desktop:url:/images/favicon.icogravatar:falseandroid:url:/images/favicon-192x192.pnggravatar:falseapple:url:/images/apple-touch-icon.pnggravatar:false# 高亮语法highlight:kimbie.dark# 博客主题色,dark, light, classic, whitecolorscheme:darkpage_width:48# rss设置rss:atom.xmlopen_graph:fb_app_id:fb_admins:twitter_id:google_plus:# disqus评论,默认不开启,需翻墙disqus:enabled:falseshortname:cactus-1# 谷歌统计google_analytics:enabled:falseid:UA-86660611-1# 百度统计baidu_analytics:enabled:falseid:2e6da3c375c8a87f5b664cea6d4cb29cgravatar:email:xiaobin_wu@yahoo.comvaline:enable:trueapp_id:xxxxxxapp_key:xxxxxxx
Valine评论系统
themes/cactus/_config.yml配置Valine,需要申请app_id,app_key
valine:enable:trueapp_id:xxxxapp_key:xxxx
themes/cactus/layout/_partial/comments.ejs,写入
<%if(theme.valine.enable) { %><scriptsrc="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script><scriptsrc='//unpkg.com/valine/dist/Valine.min.js'></script><divid="vcomments"class="blog-post-comments"></div><script>newValine({ el: '#vcomments', visitor: true, appId: '<%=theme.valine.app_id %>', appKey: '<%=theme.valine.app_key %>', placeholder: 'ヾノ≧∀≦)o来啊,快活啊!', avatar: 'robohash'}) </script><%} %>
自动部署hexo博客到阿里云服务器
创建仓库(远端服务器创建git仓库),可以使用ssh登入云服务器
mkdirblog.git&& cdblog.gitgitinit--bare
Hexo配置
deploy: type: git message: update repo: root@xx.xxx.xx.xxx:/www/wwwroot/blog.git,master
插件安装
npm installhexo-deployer-git --save
自动部署
进入到git仓库hooks目录,并创建钩子post-receive
cd/www/wwwroot/blog.git/hookstouchpost-receivevimpost-receive
输入下面脚本:
#!/bin/bash -lGIT_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_CLONErm -rf ${PUBLIC_WWW}/* cp -rf ${TMP_GIT_CLONE}/* ${PUBLIC_WWW}
更改权限
chmod+xpost-receive chmod777-R /www/wwwroot/blog chmod777-R /www/wwwroot/tmp/blog
最后部署
$ hexo g -d
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 3561739510@qq.com 举报,一经查实,本站将立刻删除。
转载请注明来自专注SEO技术,教程,推广 - 8848SEO,本文标题:《如何搭建博客?它有什么好处(教你10分钟搭建酷炫的个人博客)》
- 搜索
- 最新文章
- 热门文章
-
- SEO核心基础要素是什么?如何正确应用它们优化网站?
- 网站高质量内容更新技巧有哪些?如何保持内容的高质量更新?
- 亲测seo优化实践推广方法汇总?如何有效提升网站排名?
- 中小企业如何通过SEO优化提升在线可见性?SEO优化对中小企业有哪些具体好处?
- 搜索引擎的排名规则及算法是什么?如何优化以提高网站排名?
- 网络SEO优化外链建设的10个技巧(从内部和外部两个方面提升网站的链接品质)
- 停止SEO优化工作|停止SEO优化的理由与方法|SEO优化
- 如何做好百度seo排名优化?基础步骤有哪些?
- 网站优化实践步骤全解析(从0到1的实战指南)
- 怎么才能把网站做出排名?SEO优化有哪些关键步骤?
- 如何提升网站的用户体验?提升网站用户体验的五个关键步骤是什么?
- 哪些负面的行为在影响你的网站?如何识别和解决这些问题?
- 核心关键词如何优化?SEO优化的常见问题有哪些?
- SEO网站引擎优化基础是什么?如何有效实施?
- SEO怎么做才能有效提升网站排名?常见问题有哪些?
- 标准的SEO文章是怎样的?如何撰写才能提高搜索引擎排名?
- 如何利用百度索引分析关键词的真实热度?分析方法有哪些?
- 网站SEO优化多久才能见效?如何加速优化效果?
- 四个设计要点提高网站即时搜索可见性(打造高效可靠的即时搜索功能)
- 提升网站排名的终极攻略(15个科学方法助你在搜索引擎中脱颖而出)
- 热门tag