mcpField
G
GithubPages

GithubPages

github.com/julianobarbosa云与 DevOps1468 次安装2 天前更新
代码仓库

关于 GithubPages

GithubPages 是用于配置、部署和排查 GitHub Pages 网站的技能,按工作流涵盖域名、Jekyll、自定义构建与发布。

主要功能

  1. 01网站设置与发布指南
  2. 02自定义域名和 DNS 配置
  3. 03Jekyll 主题与设置
  4. 04GitHub Actions 构建工作流
  5. 05部署故障排查

适用场景

  1. 01创建用户或项目网站
  2. 02绑定自定义域名
  3. 03通过自定义构建发布网站
  4. 04排查发布或 HTTPS 问题

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/julianobarbosa/claude-code-skills --skill githubpages

安装后在 Claude Code 中输入/githubpages确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
ActionsWorkflows.md
BestPractices.md
DnsConfiguration.md
JekyllConfiguration.md
Troubleshooting.md
scripts/
check-site-status.sh
verify-dns.sh
workflows/
ActionsWorkflow.md
CustomDomain.md
Deploy.md
JekyllSetup.md
QuickStart.md
Troubleshoot.md

详细介绍

GitHub Pages 技能

关于部署、配置和管理 GitHub Pages 站点的完整指南。

快速参考

站点类型仓库名称URL 格式
用户/组织站点<username>.github.iohttps://<username>.github.io
项目站点任意仓库名称https://<username>.github.io/<repo>

可用性:

  • 公共仓库:GitHub Free(所有套餐)
  • 私有仓库:GitHub Pro、Team、Enterprise

工作流路由

执行工作流时,直接输出此通知:

Running the **WorkflowName** workflow from the **GithubPages** skill...
工作流触发条件文件
QuickStart“setup github pages”、“create pages site”workflows/QuickStart.md
CustomDomain“add custom domain”、“configure domain”workflows/CustomDomain.md
JekyllSetup“setup jekyll”、“add jekyll theme”workflows/JekyllSetup.md
ActionsWorkflow“custom build”、“github actions for pages”workflows/ActionsWorkflow.md
Troubleshoot“pages not working”、“fix github pages”workflows/Troubleshoot.md
Deploy“deploy to github pages”、“publish site”workflows/Deploy.md

示例

示例 1:创建新的 GitHub Pages 站点

User: "Setup GitHub Pages for my project"
→ Invokes QuickStart workflow
→ Checks if user/org or project site
→ Configures publishing source (branch or Actions)
→ Creates initial content structure
→ Verifies deployment

示例 2:添加自定义域名

User: "Add my domain example.com to GitHub Pages"
→ Invokes CustomDomain workflow
→ Determines domain type (apex vs subdomain)
→ Provides DNS configuration instructions
→ Adds CNAME file or configures via Settings
→ Enables HTTPS enforcement

示例 3:设置 Jekyll 主题

User: "Add a theme to my GitHub Pages site"
→ Invokes JekyllSetup workflow
→ Lists available supported themes
→ Configures _config.yml
→ Sets up custom CSS/layouts if needed

示例 4:使用自定义构建进行部署

User: "Deploy my Next.js site to GitHub Pages"
→ Invokes ActionsWorkflow workflow
→ Creates custom GitHub Actions workflow
→ Configures build process
→ Sets up artifact deployment

站点类型

用户/组织站点

要求:

  • 仓库名称必须为 <username>.github.io
  • 每个帐户只能有一个
  • 从默认分支发布

设置:

# Create repository named exactly: username.github.io
# Enable Pages in Settings > Pages
# Select source branch
项目站点

要求:

  • 可以使用任意仓库
  • 允许创建多个项目站点
  • URL 中包含仓库名称

设置:

# Any repository works
# Enable Pages in Settings > Pages
# Choose: branch (root or /docs) OR GitHub Actions

发布源

选项 1:从分支部署

适用场景: Jekyll 站点、简单的静态站点

配置:

  1. 转到 Settings > Pages
  2. 选择“Deploy from a branch”
  3. 选择分支(main、gh-pages 等)
  4. 选择文件夹:/(根目录)或 /docs

行为:

  • 推送到分支会触发自动构建
  • 默认情况下,Jekyll 会处理 Markdown
  • 自定义域名会自动创建 CNAME 文件
选项 2:GitHub Actions 工作流

适用场景: 自定义构建、非 Jekyll 生成器

配置:

  1. 转到 Settings > Pages
  2. 选择“GitHub Actions”
  3. 在 .github/workflows/ 中创建工作流文件

行为:

  • 可全面控制构建流程
  • 适用于 Hugo、Gatsby、Next.js 等
  • 上传并部署构建产物

Jekyll 集成

自动启用的插件

这些插件在 GitHub Pages 上会自动运行:

插件用途
jekyll-coffeescriptCoffeeScript 支持
jekyll-default-layout自动布局
jekyll-gist嵌入 GitHub Gist
jekyll-github-metadata仓库元数据
jekyll-optional-front-matter可选 YAML front matter
jekyll-paginate分页
jekyll-readme-index将 README 用作索引
jekyll-titles-from-headings自动生成标题
jekyll-relative-links转换相对链接
支持的主题

无需额外配置即可使用:

  • Architect
  • Cayman
  • Dinky
  • Hacker
  • Leap day
  • Merlot
  • Midnight
  • Minima
  • Minimal
  • Modernist
  • Slate
  • Tactile
  • Time machine

在 _config.yml 中使用:

theme: jekyll-theme-minimal
title: My Site
description: Site description
远程主题

使用 GitHub 上的任意 Jekyll 主题:

remote_theme: owner/repo-name

自定义域名

域名类型
类型示例DNS 记录
裸域名example.comA 或 ALIAS
WWW 子域名www.example.comCNAME
自定义子域名blog.example.comCNAME
DNS 配置

裸域名(A 记录):

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153

裸域名(AAAA 记录 - IPv6):

2606:50c0:8000::153
2606:50c0:8001::153
2606:50c0:8002::153
2606:50c0:8003::153

子域名(CNAME 记录):

www.example.com → username.github.io
blog.example.com → username.github.io
验证命令
# Check A records
dig example.com +noall +answer -t A

# Check AAAA records
dig example.com +noall +answer -t AAAA

# Check CNAME records
dig www.example.com +nostats +nocomments +nocmd

使用限制

资源限制
仓库大小1 GB(建议)
已发布网站大小1 GB(最大)
带宽100 GB/月(软限制)
构建次数10 次/小时(软限制,仅限分支)
部署超时10 分钟

限制:

  • 不支持服务器端语言(PHP、Python、Ruby)
  • 不得进行商业交易或电子商务
  • 必须遵守 GitHub 服务条款

安全最佳实践

  1. 验证自定义域名 - 防止域名劫持攻击
  2. 避免使用通配符 DNS - *.example.com 会带来安全风险
  3. 启用 HTTPS - 证书配置完成后,始终强制使用 HTTPS
  4. 不要暴露机密信息 - 即使仓库是私有的,网站仍可公开访问
  5. 及时更新 DNS - 如果停用网站,请更新或删除 DNS 记录

常见问题与解决方案

问题解决方案
网站未发布检查分支/文件夹设置,确认入口文件存在
404 错误确保根目录下有 index.html、index.md 或 README.md
自定义域名无法使用等待 24 小时以完成 DNS 传播,并使用 dig 验证记录
HTTPS 不可用DNS 验证完成后最多等待 1 小时
混合内容警告将所有资源中的 http:// 改为 https://
构建失败检查 Actions 选项卡中的错误日志

文件参考

主题参考文件
DNS 配置references/DnsConfiguration.md
Jekyll 配置references/JekyllConfiguration.md
Actions 工作流references/ActionsWorkflows.md
故障排除指南references/Troubleshooting.md
最佳实践references/BestPractices.md

脚本

脚本用途
scripts/verify-dns.sh验证自定义域名的 DNS 配置
scripts/check-site-status.sh检查 GitHub Pages 网站是否在线

外部文档

评论

支持 Markdown