快捷菜单
常用功能一站直达
更多功能请点顶栏「快捷菜单」
1# 构建生产版本
2make build
3
4# 或直接使用 Hugo
5./hugo --source=hugo-teek-site --minify构建产物位于 hugo-teek-site/public/ 目录。
1# 构建
2make build
3
4# 上传到服务器
5rsync -avz hugo-teek-site/public/ user@server:/var/www/html/ 1server {
2 listen 80;
3 server_name yourdomain.com;
4 root /var/www/html;
5 index index.html;
6
7 location / {
8 try_files $uri $uri/ /index.html;
9 }
10
11 # 开启 Gzip 压缩
12 gzip on;
13 gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
14}创建 .github/workflows/deploy.yml:
1name: Deploy Hugo site to Pages
2
3on:
4 push:
5 branches: ["main"]
6 workflow_dispatch:
7
8permissions:
9 contents: read
10 pages: write
11 id-token: write
12
13jobs:
14 build:
15 runs-on: ubuntu-latest
16 steps:
17 - name: Checkout
18 uses: actions/checkout@v4
19
20 - name: Setup Hugo
21 uses: peaceiris/actions-hugo@v2
22 with:
23 hugo-version: '0.150.0'
24 extended: true
25
26 - name: Setup Go
27 uses: actions/setup-go@v4
28 with:
29 go-version: '1.21'
30
31 - name: Build
32 run: |
33 make install-deps
34 make build
35
36 - name: Upload artifact
37 uses: actions/upload-pages-artifact@v2
38 with:
39 path: ./hugo-teek-site/public
40
41 deploy:
42 environment:
43 name: github-pages
44 url: ${{ steps.deployment.outputs.page_url }}
45 runs-on: ubuntu-latest
46 needs: build
47 steps:
48 - name: Deploy to GitHub Pages
49 id: deployment
50 uses: actions/deploy-pages@v2创建 Dockerfile:
1FROM hugomods/hugo:exts as builder
2
3WORKDIR /src
4COPY . .
5RUN make build
6
7FROM nginx:alpine
8COPY --from=builder /src/hugo-teek-site/public /usr/share/nginx/html
9EXPOSE 80构建并运行:
1docker build -t hugo-teek-blog .
2docker run -d -p 80:80 hugo-teek-blog日历 · 精选 · 友链 · 更多
如果内容对你有帮助,欢迎请我喝杯咖啡 ☕



One的公众号
爱折腾博客的小白