找到
35
篇与
ioip的博客
相关的结果
- 第 3 页
-
butterfly主题在hexo中的配置 1. 安装Butterfly主题 方法一:Git克隆(推荐) bash cd themes git clone https://github.com/jerryc127/hexo-theme-butterfly.git --depth=1 方法二:手动下载 从Butterfly Releases下载最新版 解压到themes/butterfly目录 2. 去除子模块绑定 步骤说明 bash 解除子模块关联 git rm --cached themes/butterfly rm -rf themes/butterfly/.git 清理残留配置(可选) git config -f .gitmodules --remove-section submodule.themes/butterfly rm -rf .git/modules/themes/butterfly 文件结构验证 确保处理后目录包含: themes/butterfly/ ├── _config.yml # 主配置文件(27KB) ├── layout/ # 模板文件 ├── source/ # 静态资源 ├── scripts/ # 脚本文件 └── languages/ # 多语言文件 3. 推送到GitHub仓库 配置Hexo 修改_config.yml: yaml theme: butterfly 提交变更 bash git add themes/butterfly git commit -m "feat: 添加butterfly主题并解除子模块" git push origin main 4. 主题更新方法 手动更新 备份_config.yml和自定义文件 覆盖themes/butterfly目录 恢复配置文件 自动化建议 yaml .github/workflows/update-theme.yml jobs: update: steps: uses: actions/checkout@v4 run: | rm -rf themes/butterfly git clone https://github.com/jerryc127/hexo-theme-butterfly themes/butterfly cp custom_config.yml themes/butterfly/_config.yml 注意事项 操作前备份_config.yml(27KB配置文件) 不要提交themes/butterfly/.github/目录 使用.gitignore过滤临时文件: themes/butterfly/.github/ themes/butterfly/node_modules/ ioip图片 -
使用github actions部署hexo博客 参考文章 如何优雅的使用Github Action服务来将Hexo部署到Github Pages HEXO系列教程 | 使用GitHub部署静态博客HEXO | 小白向教程 GitHub 创建仓库 注册并登录一个GitHub账户 【注册方法2.2 准备 GitHub】 github-1图片 主界面图片 点击头像,进入仓库 主界面-头像图片 仓库空图片 创建仓库【仓库名字为xx.github.io,并不一定非要使用你的github的用户名作为xx,可以进行自定义,如我的为ioip.github.io】 新建仓库图片 建好了图片 获取token 点击头像 -> Settings -> Developer Settings setting图片 在个人设置中新增一个Personal access tokens。至少要包含repo权限,然后记住token。 这个token是给Github Action用的,Github Action会把Hexo编译部署到gh-pages分支。 token1图片 token2图片 token3图片 token4图片 将token填入仓库 随后在存放Hexo代码的仓库里把这个Token新增进去,名称为GH_TOKEN(随意,后面需要一致)。 【注意:先回到仓库再点击setting】 miyao1图片 密钥2图片 秒哟3图片 获取ssh密钥【用于解决推送文件时GitHub国内的网络问题】 你需要在本地电脑上面安装: nodejs(>16 版本,最新的应该有 20 版本):Node.js — Run JavaScript Everywhere git(2.44.0):Git – Downloads 在某一个盘里面创建一个文件夹,名字叫 hexo,然后右键选择 Open Git Bash Here。 我们在里面输入 bash git config --global user.name "你的 GitHub 用户名" git config --global user.email "你的 GitHub 邮箱" 我们在命令行窗口中输入 bash ssh-keygen -t rsa -C "你的 GitHub 邮箱" 什么都不用管,一路回车就行。然后我们进入 C:Users用户名.ssh 目录(勾选显示 “隐藏的项目”) 我们用记事本打开 id_rsa.pub 并复制里面的内容。 keyssh1图片 这个时候我们回到 GitHub,进入 Settings: keyssh2图片 选择左边栏的 SSH and GPG keys,点击 New SSH key: keyssh3图片 Title 随便取,然后把 id_rsa.pub 里面的内容复制到 Key 中,点击 Add SSH key: keyssh4图片 保存完毕以后,我们可以在本地验证一下连接。依旧在 Git Bash Here 界面中输入 bash ssh -T git@github.com 出现 “Are you sure……”,输入 yes 回车确认。若出现下图的提示即连接成功: keyssh4图片 切换到ssh用于解决推送文件时GitHub国内的网络问题 bash git remote set-url origin git@github.com:luojunchong/PLAN.git 本地配置HEXO 初始化Hexo 安装脚手架,初始化hexo,进入之前新建的hexo文件夹,进入后安装依赖。 bash npm install -g hexo-cli hexo init blog cd blog npm install 初始化仓库 bash git init git remote add origin https://github.com/yourusername/your-repo.git git add . git commit -m "Initial commit" git push -u origin main 配置Github Action工作流 在 .github 文件夹下新增 workflows 文件夹,然后新增 deploy.yml 文件,内容如下。 里面有个 node-version 要和你本地的 node 一致。【使用 node -v 获取】 步骤大致意思就是使用 ubuntu-latest 作为基础环境,然后安装各种依赖,随后 hexo generate 生成博客网站静态文件夹, 把这个文件夹推送到同一仓库的 gh-pages 分支。 yaml name: Deploy Hexo to GitHub Pages on: push: branches: main # 当推送到 main 分支时触发 jobs: build: runs-on: ubuntu-latest steps: name: Checkout repository uses: actions/checkout@v2 with: submodules: false # 禁用子模块检查 name: Setup Node.js uses: actions/setup-node@v2 with: node-version: '18' # 注意:这里的版本号需要用引号括起来 name: Install Dependencies run: npm install name: Install Hexo Git Deployer run: | npm install hexo-deployer-git --save npm install hexo-cli -g name: Clean and Generate Static Files run: | hexo clean hexo generate name: Configure Git run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' name: Deploy to GitHub Pages env: GH_TOKEN: {{ secrets.GH_TOKEN }} run: | cd public/ git init git add -A git commit -m "Create by workflows" git remote add origin https://{{ secrets.GH_TOKEN }}@github.com/yourusername/your-repo.git git push origin HEAD:gh-pages -f 推送验证 把刚才更新的所有文件都推送一遍,github就会触发工作流,然后去网站看工作流运转的如何。 等一切运转完毕,就会发现仓库多出一个gh-pages分支。 bash git add . git commit -m "Initial commit 2" git push -u origin main 配置Github Pages 在仓库settings中配置page来源为gh-pages分支即可。等待网站部署完毕,就可以看了。网站链接可以在settings的GitHub Pages看到,也可以去action里看到。 img3图片 ioio图片