当前位置: 首页 > news >正文

Hugo托管到Github Pages

Github通过其Github Pages服务可以user、project或organization提供免费快速的静态托管,同时使用Github Actions自动化开发工作流和构建。

1.创建Github仓库

可见性为public。

命名为username.github.io,username为你的Github用户名。

2.添加远程仓库

添加主题前,我们就已经使用git init初始化了Hugo网站项目。

现在,我们给它关联刚创建的远程仓库username.github.io

git remote add origin https://github.com/Shadow-Kylin//Shadow-Kylin.github.io.git

3.构建网站

hugo

4.推送到github

git chekcout -m master main
git add .
git commit -m "init commit"
git push origin main

5.修改Pages

image-20230824231445732

6.在本地仓库中创建空文件

 mkdir -p .github/workflowstouch .github/workflows/hugo.yaml

复制下面内容到刚创建的hugo.yaml

# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pageson:# Runs on pushes targeting the default branchpush:branches:- main# Allows you to run this workflow manually from the Actions tabworkflow_dispatch:# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:contents: readpages: writeid-token: write# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:group: "pages"cancel-in-progress: false# Default to bash
defaults:run:shell: bashjobs:# Build jobbuild:runs-on: ubuntu-latestenv:HUGO_VERSION: 0.115.4steps:- name: Install Hugo CLIrun: |wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \&& sudo dpkg -i ${{ runner.temp }}/hugo.deb          - name: Install Dart Sassrun: sudo snap install dart-sass- name: Checkoutuses: actions/checkout@v3with:submodules: recursivefetch-depth: 0- name: Setup Pagesid: pagesuses: actions/configure-pages@v3- name: Install Node.js dependenciesrun: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"- name: Build with Hugoenv:# For maximum backward compatibility with Hugo modulesHUGO_ENVIRONMENT: productionHUGO_ENV: productionrun: |hugo \--gc \--minify \--baseURL "${{ steps.pages.outputs.base_url }}/"          - name: Upload artifactuses: actions/upload-pages-artifact@v1with:path: ./public# Deployment jobdeploy:environment:name: github-pagesurl: ${{ steps.deployment.outputs.page_url }}runs-on: ubuntu-latestneeds: buildsteps:- name: Deploy to GitHub Pagesid: deploymentuses: actions/deploy-pages@v2

我们只需修改branch名称和Hugo的版本即可。

7.提交修改

git add .
git commit -m "Add workflow"
git push origin main

8.查看部署状态

image-20230824233051384

如此之后,每当你从本地存储库中推送更改时,GitHub都将重建您的站点并部署更改。

欢迎访问影麟的Hugo博客。

http://www.lryc.cn/news/139391.html

相关文章:

  • Python经典面试题——在txt里面添加字段和数据
  • 【观察】打造以AI为导向的基础设施,联想锚定AI算力“主航道”
  • 预防缓存穿透工具类
  • 会员管理系统实战开发教程04-会员开卡
  • 数据结构(2)
  • 使用ELK(ES+Logstash+Filebeat+Kibana)收集nginx的日志
  • TDengine server连接遇到的坑
  • 什么是NetDevOps
  • 中小金融机构数字化转型最大的挑战是什么?
  • Facebook HiPlot “让理解高维数据变得容易”
  • 【python】:python新设备环境移植(requirements.txt)
  • 分类预测 | MATLAB实现1D-2D-CNN-GRU的多通道输入数据分类预测
  • 【LeetCode】125. 验证回文串 - 双指针
  • centos7设置java后端项目开机自启【脚本、开机自启】
  • 亿赛通电子文档安全管理系统 RCE漏洞复现(QVD-2023-19262)
  • 一文读懂 Nuxt.js 服务端组件
  • LeetCode--HOT100题(39)
  • “车-路-网”电动汽车充电负荷时空分布预测(matlab)
  • 【核磁共振成像】方格化重建
  • JAVA中时间戳和LocalDateTime的互转
  • 无涯教程-进程 - 创建终止
  • LLMs参考资料第一周以及BloombergGPT特定领域的训练 Domain-specific training: BloombergGPT
  • LeetCode字符串数组最长公共前缀
  • Git gui教程---第八篇 Git gui的使用 创建一个分支
  • Docker修改daemon.json添加日志后无法启动的问题
  • QT6编译的文件分布情况
  • 2023中国算力大会 | 中科驭数加入DPU推进计划,探讨DPU如何激活算网融合新基建
  • leetcode 115. 不同的子序列
  • gradio应用transformer模块部署生成式人工智能应用程序
  • 【目标检测】“复制-粘贴 copy-paste” 数据增强实现