如何搭建博客?它有什么好處(教你10分鐘搭建酷炫的個(gè)人博客) DATE: 2026-05-05 07:49:44
準備工作
安裝
$npm??install-ghexo-cli
初始化
$hexoinit<folder>$cd<folder>$npminstall
創(chuàng )建新文章
$hexonew"MyNewPos??t"
運行開(kāi)發(fā)環(huán)境
$hexoserver$hexos
構建
$hexogenerate$hexog部署
$hexodeploy$hexod詳細準備工作,何搭可以查閱hexo官網(wǎng)
安裝主題cactus,建博一個(gè)很程序(′Д` )員的客有酷炫客主題,推薦!什好
克隆倉庫,處教并且將源文件復制到博客項目中themes目錄下
gitclonehttps://github.com/probberechts/hexo-theme-cactus.gitthemes/cactusthe??mes/cactus/_config(′ω`).yml相關(guān)配置,分鐘詳細解釋可以看官方文檔
#首頁(yè)Projects的urlprojects_url:https://??github.com/xiaobinwu#設置頁(yè)面(mian)方向direction:ltr#首頁(yè)導航#$hexonewpageabout,可以創(chuàng )建page頁(yè)面nav:home:/about:/about/articles:/archives/categories:/categories/search:/search/#社交鏈接social_links:github:https://??github.com/xiaoヾ(′▽?zhuān)??bi(′;д;`)nw??umail:mailto:[email protected]#開(kāi)啟標簽??快捷方式tags_overview:true#首頁(yè)Writing的搭建展示條數posts_overview:show_all_posts:falsepost_??count:5sort_updated:false#排列方式archive:sort_uヽ(′▽?zhuān)?ノpdated:falsepost:show_updated:(′?`*)false#logo設置logo:enabled:truewidth(′ω`):50height:50url:/images/lo??go.pnggravatar:false#i??co設置favicon:d??esktop:url:/images/favicon.icogravatar:falseandroid:url:/images/favicon-192x192.pnggravatar:falseapple:url:/images/apple-touch-icon.pnggravatar:false#高亮語(yǔ)法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評論,默認不(bu)開(kāi)啟,??何搭需翻墻disqus:enabled:fa??lseshortn??ame:cactus-1#谷歌統計google_analytics:enabled:falseid:UA-86660611??-1#百度統計baidu_analytics:enabled:falseid:2e6da3c375c8a87f5b664cea6d4cb29cgravatar:email:[email protected]:enable:trueapp_id:xxxxxxapp_key:xxxxxxx
Valine評論系統
themes/cactus/_config.yml配置Valinヽ(′?`)ノe,建博需(°o°)要申請app_id,客有酷炫客app_key
valine:enable:tru??eapp_id:xxxxapp_key:xxxx
themes/cactus/layout/_partia??l/comments.ejs,什好寫(xiě)入
<%if(theme.valine.enable){ %><scriptsrc="//cdn1.lncld.net/static/js/3.0.4/av-min.js"ヽ(′▽?zhuān)?ノ></script><scriptsrc='//unpkg.(′Д` )com/valine/dist/Valin(′Д` )e.m??in.js&(′;д;`)#39;></script><divid="vcomments"class="blog-post-comments"></div><script>newValine({ el:??9;#vcomments',visitor:true,appId:'<%=theme.valine.app_id%>( ?° ?? ?°)'(╯°□°)╯,appKey:'(′?`*);<%=theme.va??line.app_key%&??gt;',placeholder:'ヾ?≧?≦)o來(lái)啊,快活啊!'??,處教avatar:'robohash??39;})</script><%}%>自動(dòng)部署hexo博客到阿里云服務(wù)器
創(chuàng )建倉庫(遠端服務(wù)器創(chuàng )建git倉庫),可以??使用ssh登入云服務(wù)器
mkdirblog.git&a???mp;&cdblog.gitgitinit--bareHexo配置
deploy:type:gitmessage:updaterepo:[email protected]:/www/wwwroot/blog.git,master
插件安裝
npminstallhexo-deployer-git--save自動(dòng)部署
進(jìn)入到git倉庫hooks目錄,并創(chuàng )建鉤子post-receive
cd/www/wwwroot/blog.git/h(′_`)ookstouchpost-receivevimpost-receive
輸入下面腳本:
#!/bin/bash-lGIT_REPO=/www/wwwroot/blog.gitTMP_GIT_CLONE=/ww(′?`*)w/wwwroot/tm(°o°)p/blogPUBLIC_WWW=/www/wwwroot/blogrm-rf${ TMヽ(′▽?zhuān)?ノP_GIT_CLONE}mkdir${ TMP_GIT_CLONE}gitclone$GIT_REPO$TMP_GIT_CLONErm-rf${ PUBLIC_WWW}/*cp-rf${ TMP_GIT_CLONE}/*${ PUBLIC_WWW}更改權限??
chmod+xpost-receivechmod777-R/www/wwwroot/blogchmod777-R/www/wwwro??ot/tmp/blog
最后部署
$hexog-d
版權聲明:本文內??容由互聯(lián)網(wǎng)用戶(hù)自發(fā)貢獻,分鐘該文觀(guān)點(diǎn)僅代表作者本人。搭建本站僅提供信息存儲空間服務(wù),不擁有所有權,不承擔相??關(guān)法律責任(╯‵□′)╯。如發(fā)現本站有涉嫌抄襲侵權/違法違規的內容, 請發(fā)送郵件至 1817475(′?_?`)@qq.com 舉報,一經(jīng)查實(shí),本站將立刻刪除。

