Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ymj4023 的博客

这是一个无外部主题依赖的 Hugo 中文博客。源码保存在 main 分支;每次推送后,GitHub Actions 会构建 public/ 并直接部署到 GitHub Pages。

线上地址:https://ymj4023.github.io/

本地预览

先安装 Hugo Extended,建议使用 0.164.0 或兼容的新版本。

cd D:\ymj\gitwork\ymj4023.github.io
hugo server

打开终端显示的本地网址即可预览。需要同时显示草稿时运行 hugo server -D

发布文章

新文章放在 content/posts

hugo new content posts/my-new-post.md

编辑生成的 Markdown 文件,把 front matter 中的 draft 改为 false(或删除该字段),然后提交并推送:

git add .
git commit -m "content: publish a new post"
git push

首次连接 GitHub

  1. 在 GitHub 创建一个名为 ymj4023.github.io 的仓库。用户主页仓库名必须与账号名完全一致。

  2. 不要在 GitHub 端额外生成 README、.gitignore 或许可证,避免首次推送发生历史冲突。

  3. 在本地仓库中连接远程并推送:

    git remote add origin https://github.com/ymj4023/ymj4023.github.io.git
    git push -u origin main
  4. 打开仓库的 Settings → Pages

  5. Build and deployment 下,把 Source 设为 GitHub Actions

  6. 打开 Actions 页面,等待 Build and deploy Hugo site 工作流变绿。

  7. 访问 https://ymj4023.github.io/

项目结构

.github/workflows/hugo.yaml  自动构建与部署
content/posts/               Markdown 文章
layouts/                     Hugo 页面模板
static/css/site.css          响应式样式
hugo.yaml                    站点配置
tests/verify.ps1             本地验收测试

运行完整验收测试:

.\tests\verify.ps1 -HugoPath "C:\path\to\hugo.exe"

构建产物不提交到仓库;GitHub Actions 会在部署时重新生成 public/

About

Hugo blog deployed automatically with GitHub Actions and GitHub Pages

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages