
PaperUI 博客部署到生产环境的完整方案
上一篇聊了 SEO 优化,这篇我们讲部署 —— 把本地写好的 PaperUI 博客发布到互联网上。 构建静态文件 在部署之前,先生成静态文件: # 清理旧文件并重新构建(--cleanDestinationDir 自动清理废弃文件) hugo --minify --cleanDestinationDir --minify 参数会压缩 HTML、CSS、JS,减小文件体积。构建后的文件在 public/ 目录中。 方案一:GitHub Pages(免费) 适用场景 使用 GitHub 管理博客源代码 免费托管 自定义域名支持 步骤 1. 创建部署仓库 在 GitHub 上创建 用户名.github.io 仓库(用于用户/组织站点)。 2. 推送代码 cd my-blog git init git remote add origin https://github.com/用户名/用户名.github.io.git git add . git commit -m "初始化博客" git push -u origin main 3. 配置 GitHub Actions 创建 .github/workflows/deploy.yml: name: Deploy Hugo site on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: true fetch-depth: 0 - name: Setup Hugo uses: peaceiris/actions-hugo@v3 with: hugo-version: '0.146.0' extended: true - name: Build run: hugo --minify --cleanDestinationDir - name: Deploy uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public 4. 设置 GitHub Pages ...


