[{"data":1,"prerenderedAt":272},["ShallowReactive",2],{"content:\u002F2022\u002F34548":3,"surround:\u002F2022\u002F34548":266},{"id":4,"title":5,"body":6,"categories":240,"date":242,"description":243,"draft":244,"extension":245,"image":246,"meta":247,"navigation":249,"path":250,"permalink":251,"published":251,"readingTime":252,"recommend":257,"references":251,"seo":258,"sitemap":259,"stem":260,"tags":261,"type":264,"updated":242,"__hash__":265},"content\u002Fposts\u002F2022\u002F34548.md","Termux部署hexo",{"type":7,"value":8,"toc":231},"minimark",[9,13,20,31,36,42,47,53,58,64,69,75,82,87,93,105,108,113,119,124,130,135,139,145,150,156,161,166,172,181,186,194,197,203,213,217,223,226],[10,11,12],"h3",{"id":12},"本地安装",[14,15,16],"ul",{},[17,18,19],"li",{},"打开termux,输入:",[21,22,27],"pre",{"className":23,"code":25,"language":26},[24],"language-text","pkg update && pkg upgrade -y\n","text",[28,29,25],"code",{"__ignoreMap":30},"",[14,32,33],{},[17,34,35],{},"待更新完成后，安装一些必要的工具:",[21,37,40],{"className":38,"code":39,"language":26},[24],"pkg install nodejs-lts vim git  -y\n",[28,41,39],{"__ignoreMap":30},[14,43,44],{},[17,45,46],{},"再是使用淘宝镜像:",[21,48,51],{"className":49,"code":50,"language":26},[24],"npm config set registry http:\u002F\u002Fregistry.npm.taobao.org\n",[28,52,50],{"__ignoreMap":30},[14,54,55],{},[17,56,57],{},"接着就是安装hexo:",[21,59,62],{"className":60,"code":61,"language":26},[24],"npm install hexo-cli -g\n",[28,63,61],{"__ignoreMap":30},[14,65,66],{},[17,67,68],{},"再来初始化文件:",[21,70,73],{"className":71,"code":72,"language":26},[24],"hexo init blog\ncd blog\nnpm install\n",[28,74,72],{"__ignoreMap":30},[76,77,78],"blockquote",{},[79,80,81],"p",{},"注:此时的blog文件夹里存放的就是hexo博客系统的核心文件，以后你的文章创作和主题配置都要在此目录下完成，(此时的文件夹可以任意取名，不是非要叫blog)",[14,83,84],{},[17,85,86],{},"接着就是启动本地服务器:",[21,88,91],{"className":89,"code":90,"language":26},[24],"hexo s\n",[28,92,90],{"__ignoreMap":30},[76,94,95],{},[79,96,97,98,104],{},"正常启动之后，在浏览器输入：",[99,100,101],"a",{"href":101,"rel":102},"http:\u002F\u002Flocalhost:4000\u002F",[103],"nofollow"," 这时候就能看到我们已经搭好的Hexo博客了!",[10,106,107],{"id":107},"部署到github",[76,109,110],{},[79,111,112],{},"首先你需要先在github建一个仓库，名为 username.github.io， username就是你的github用户名,接着安装openssh:",[21,114,117],{"className":115,"code":116,"language":26},[24],"pkg install openssh -y\n",[28,118,116],{"__ignoreMap":30},[14,120,121],{},[17,122,123],{},"然后输入:",[21,125,128],{"className":126,"code":127,"language":26},[24],"git config --global user.name \"yourname\"\ngit config --global user.email \"youremail\"\n",[28,129,127],{"__ignoreMap":30},[76,131,132],{},[79,133,134],{},"这里的yourname输入你的GitHub用户名，youremail输入你注册GitHub用的邮箱。",[10,136,138],{"id":137},"创建ssh","创建ssh:",[21,140,143],{"className":141,"code":142,"language":26},[24],"ssh-keygen -t rsa -C \"youremail\"\n",[28,144,142],{"__ignoreMap":30},[14,146,147],{},[17,148,149],{},"然后回车三次，输入:",[21,151,154],{"className":152,"code":153,"language":26},[24],"cat \u002Fdata\u002Fdata\u002Fcom.termux\u002Ffiles\u002Fhome\u002F.ssh\u002Fid_rsa.pub\n",[28,155,153],{"__ignoreMap":30},[76,157,158],{},[79,159,160],{},"此时显示的就是就是一个ssh秘钥，在github首页上，点击自己的头像，点击下面的setting,再找到_SSH and GPG keys_,添加ssh key。",[14,162,163],{},[17,164,165],{},"查看是否成功，输入:",[21,167,170],{"className":168,"code":169,"language":26},[24],"ssh -T git@github.com\n",[28,171,169],{"__ignoreMap":30},[76,173,174],{},[79,175,176,177,180],{},"如果出现yes&no的问题，选yes即可，当看到:\n",[28,178,179],{"code":179},"Hi username You've successfully authenticated, but GitHub does not provide shell access.","\n就代表已经成功了！",[14,182,183],{},[17,184,185],{},"接着在blog目录下找到_config.yml,翻到最后，修改为:",[21,187,192],{"className":188,"code":190,"language":191,"meta":30},[189],"language-sh","# Deployment\n  ## Docs: https:\u002F\u002Fhexo.io\u002Fdocs\u002Fdeployment.html\n  deploy:\n      type: git\n      repo: git@github.com:username\u002Fusername.github.io.git\n      branch: master\n      ``` \n- 再在blog目录下安装一个插件，来完成推送到github的事:\n\n","sh",[28,193,190],{"__ignoreMap":30},[79,195,196],{},"npm install hexo-deployer-git --save",[21,198,201],{"className":199,"code":200,"language":26},[24],"\n- 接着:\n\n``` ccs\nhexo g -d\n",[28,202,200],{"__ignoreMap":30},[76,204,205],{},[79,206,207,208,212],{},"你就可以在 ",[99,209,210],{"href":210,"rel":211},"https:\u002F\u002Fusername.github.io\u002F",[103]," 看到自己的网站了！",[10,214,216],{"id":215},"常用命令","常用命令:",[21,218,221],{"className":219,"code":220,"language":191,"meta":30},[189],"hexo help  #帮助\nhexo clean  #清除缓存和已生成的静态文件\nhexo new \"name\" # 新建文章 \nhexo new page \"name\" # 新建页面\nhexo g # 生成静态页面\nhexo s   #本地预览\nhexo d  #部署\nhexo g -d  #生成页面并部署\n",[28,222,220],{"__ignoreMap":30},[10,224,225],{"id":225},"域名绑定",[76,227,228],{},[79,229,230],{},"在任意网站购得域名，然后登录GitHub，进入之前创建的仓库，点击settings，设置Custom domain，输入你所购的域名，然后在你创建的博客文件夹blog下的source目录中创建一个名为CNAME文件，不要后缀。写上你的域名。",{"title":30,"searchDepth":232,"depth":232,"links":233},4,[234,236,237,238,239],{"id":12,"depth":235,"text":12},3,{"id":107,"depth":235,"text":107},{"id":137,"depth":235,"text":138},{"id":215,"depth":235,"text":216},{"id":225,"depth":235,"text":225},[241],"技术","2022-10-06 13:26:50","本文详细介绍了如何在 **Termux** 环境中本地安装并部署 **Hexo** 博客系统，并将其发布到 **GitHub Pages** 上。",false,"md","https:\u002F\u002Fimg.zhkax.cn\u002Fcover\u002F1.webp",{"slots":248},{},true,"\u002F2022\u002F34548",null,{"text":253,"minutes":254,"time":255,"words":256},"3 min read",2.895,173700,579,1,{"title":5,"description":243},{"loc":250},"posts\u002F2022\u002F34548",[262,263],"Hexo","博客","post","b7C_KWD_9HWHtqJrSV6sYnsfMFB43ntdMiyEN2Oxe7A",[251,267],{"title":268,"path":269,"stem":270,"date":271,"type":264,"children":-1},"Vercel+GitHub 双端自动部署","\u002F2024\u002F24548","posts\u002F2024\u002F24548","2024-07-20 00:00:00",1787456845869]