如何搭建博客?它有什么好处(教你10分钟搭建酷炫的个人博客)
三石哥
2022-07-16 17:42:35
327
准备工作
安装
$ 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分钟搭建酷炫的个人博客)》
- 搜索
- 最新文章
- 热门文章
-
- 免费的ppt模板下载网站有哪些?如何选择适合自己的免费ppt模板下载网站?
- 哔哩哔哩缓存视频存放在哪个文件夹?如何清理缓存视频?
- 高清图片素材网站有哪些?如何选择高清图片素材网站?
- SEO怎么快速提高排名?有哪些有效的SEO策略?
- 如何创建网站?新手应该注意哪些问题?
- 建网站需要注意什么?有哪些常见问题和解决方案?
- seo如何优化关键词排名?有哪些技巧和方法?
- 哔哩哔哩缓存视频导出方法是什么?如何保存到电脑?
- 合肥网站开发需要多少钱?开发流程是怎样的?
- 个人建设网站制作的常见问题有哪些?
- 免费logo设计网站如何使用?常见问题有哪些?
- 网站推广有哪些有效方法?如何有效提高网站流量?
- seo什么意思?seo的含义和重要性是什么?
- unsplash素材网站如何使用?如何找到高质量的素材?
- 游戏素材网站有哪些?选择合适的游戏素材网站需要注意什么?
- 网站页面设计要点有哪些?提升用户体验的有效方法是什么?
- 哔哩哔哩缓存视频导出保存方法?如何将视频保存到手机上?
- 如何选择适合自己的免费word文档模板下载网站?
- 关键词是什么意思?如何选择合适的关键词?
- 关键词策略在SEO中的重要性是什么?如何制定?
- 热门tag