Github创建个人博客

这篇博客介绍了如何在GitHub上创建一个新的repository,设置域名为.github.io,并配置.gitignore文件忽略Node相关内容。接着,通过编辑和推送代码,将'Hello World'打印到HTML页面,并利用GitHub Pages发布静态网站。作者还探讨了选择不同模板,如Hugo、Jekyll和Hexo的主题来美化网站,并提供了模板资源链接。最后,展示了网站生效前需要等待一段时间,并邀请读者查看最终效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、Create a new repository

设置域名:.github.io

设置.gitignore:Node

2、打印一个hello到html

GitHub Pages | Websites for you and your projects, hosted directly from your GitHub repository. Just edit, push, and your changes are live.Websites for you and your projects, hosted directly from your GitHub repository. Just edit, push, and your changes are live.https://pages.github.com/

git clone https://github.com/tobeprozy/tobeprozyRecord.github.io.git

cd .\tobeprozyRecord.github.io\  

echo "Hello World" > index.html

git add --all

git commit -m "Initial commit"

git push -u origin main

3、Setting->pages->Branch

 

 好像要过一会才会显示这个网址,自己玩会去

 

 4、看效果

5、弄个模板看看

Complete List | Hugo Themeshttps://themes.gohugo.io/Jekyll Themesicon-default.png?t=M85Bhttp://jekyllthemes.org/page3/Themes | HexoHexo is a fast, simple & powerful blog framework powered by Node.js.https://hexo.io/themes/这个还不错

HCZ Materialicon-default.png?t=M85Bhttp://jekyllthemes.org/themes/hcz-jekyll-material/下载,拖进来

 

看效果

 

### 如何在 GitHub 上部署个人博客 #### 使用 GitHub Pages 和 Hugo 搭建静态网站教程 为了创建并部署基于 Hugo 的静态博客GitHub Pages,需遵循一系列配置步骤。 #### 准备工作环境 安装 Hugo 构建工具是必要的前提条件。确保本地计算机已成功安装 Hugo 版本[^1]。 #### 初始化 Git 仓库并与 GitHub 关联 首先,在本地初始化一个新的 Git 仓库,并将其关联至远程 GitHub 仓库: ```bash git init git remote add origin git@github.com:<用户名>/<仓库名>.git ``` #### 配置 Hugo 网站设置 编辑 `config.toml` 文件来定义站点的基础 URL 地址,这一步骤对于正确构建和发布至关重要: ```toml baseURL = "https://<用户名>.github.io/<仓库名>" languageCode = "zh-cn" title = "我的Hugo博客" theme = "<所选主题名称>" ``` #### 设置 GitHub Actions 自动化流程 为实现自动化部署,应在 `.github/workflows/` 目录下创建名为 `deploy.yml` 的 YAML 文件,用于编写 CI/CD 流程脚本。此文件负责触发每次提交后的自动编译与推送操作: ```yaml name: Deploy to GitHub Pages on: push: branches: - main jobs: build-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: hugo-version: 'latest' - name: Build site run: | hugo - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public ``` #### 开启 GitHub Pages 功能 进入 GitHub 项目的 Settings 页面,找到 Pages 菜单选项,选择源分支为 `gh-pages` 并保存更改。注意这里的分支名字必须严格匹配 `gh-pages`。 完成上述所有配置之后,任何推送到默认分支(通常是 `main` 或者 `master`)上的更新都会触发 GitHub Actions 来重新构建站点并将生成的内容同步到 `gh-pages` 分支上供公网访问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

南叔先生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值