Skip to content

Fix Jekyll rendering issue: remove .nojekyll and configure baseurl - #2

Draft
gravity-wh with Copilot wants to merge 3 commits into
copilot/customize-blog-accessibilityfrom
copilot/fix-jekyll-page-rendering
Draft

gravity-wh with Copilot wants to merge 3 commits into
copilot/customize-blog-accessibilityfrom
copilot/fix-jekyll-page-rendering

Conversation

Copilot AI commented Oct 10, 2025 •

Copy link
Copy Markdown

Problem

The site at https://gravity-wh.github.io/My-Blog/ was displaying raw front matter text instead of rendering the Jekyll theme properly. Users saw:

--- layout: home # Index page ---

Instead of the expected blog homepage with posts and theme styling.

Root Cause

The issue was caused by three problems:

  1. .nojekyll file present - This file explicitly tells GitHub Pages to skip Jekyll processing and serve raw files directly
  2. Invalid front matter syntax - The index.html contained a comment within the YAML front matter that could cause parsing issues
  3. Missing baseurl configuration - The site is deployed as a project site (/My-Blog) but baseurl was empty, causing asset paths to fail

Changes

1. Removed .nojekyll file

This file prevents Jekyll from processing the site. Since the repository uses Jekyll with the Chirpy theme and has a proper _config.yml, this file should not exist.

2. Fixed index.html front matter

Before:

---
layout: home
# Index page
---

After:

---
layout: home
---

Comments within YAML front matter should be avoided to prevent parsing issues.

3. Configured baseurl

Before: baseurl: ""
After: baseurl: "/My-Blog"

Since this is a project site (not a user/organization site), the baseurl must match the repository name for proper asset loading and navigation.

4. Updated .gitignore

Added .nojekyll to prevent accidental re-addition.

Testing

  • ✅ Site builds successfully with bundle exec jekyll build
  • ✅ Generated HTML contains proper markup, meta tags, and SEO tags
  • ✅ Homepage displays blog post list correctly
  • ✅ All asset paths include the correct /My-Blog/ prefix
  • ✅ Navigation links work correctly

Result

After these changes are deployed, the site will properly render with the Chirpy theme, display blog posts on the homepage, and all assets will load correctly.

Original prompt

Copilot said: 你的站点 https://gravity-wh.github.io/My-Blog/ 可以访问,但内容只显示 "--- layout: home #
你的站点 https://gravity-wh.github.io/My-Blog/ 可以访问,但内容只显示 "--- layout: home # Index page ---",这说明 Jekyll 没有正确地渲染页面模板,而是直接把你的源码内容原样输出了。常见原因和解决办法如下:

  1. 没有被 Jekyll 正确渲染
    如果页面只显示 "--- layout: home # Index page ---",说明 Jekyll 没有识别 front matter 或没有正确处理布局。

可能原因与解决方法
文件扩展名错误

你的首页文件应该是 index.md 或 index.html,而不是 index.txt 等。
确认首页文件名为 index.md 或 index.html。
文件头部 Front Matter 格式不对

Front Matter 必须用 三个短横线 --- 包围(开头和结尾),比如:
Code

layout: home
title: My Blog

不能只有一行或者没有包裹。
Jekyll 没有被 GitHub Pages 启用

检查仓库根目录下是否有 _config.yml 文件,没有的话需要新建一个。
主题配置问题

如果你使用自定义主题,确保在 _config.yml 里有正确配置 theme 或 remote_theme。
_layouts/home.html 文件缺失

如果你用 layout: home,仓库的 _layouts 目录下需要有 home.html 模板文件。
如果主题提供该布局,确保 theme 设置无误。
2. 检查 _config.yml
你的 _config.yml 应包含如下内容(示例):

YAML
title: My Blog
description: >- # your description here
theme: minima # 或者你使用的其他主题名
3. 参考例子
假设你希望首页显示主题内容,index.md 应该长这样:

index.md

layout: home
title: My Blog

欢迎来到我的博客!

  1. 一键排查清单
    仓库根目录下有 _config.yml
    仓库根目录下有 index.md 或 index.html,内容如上
    _layouts 目录下有 home.html(如果自定义主题)
    _config.yml 里设置了正确 theme,比如 theme: minima 或 remote_theme: your/theme
    文件名和扩展名无误,Front Matter 正确
    如果你需要,我可以帮你生成一个标准的 index.md 和 _config.yml 文件内容。直接帮我自动修复?

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 10, 2025 14:52
… matter

Co-authored-by: gravity-wh <114725356+gravity-wh@users.noreply.github.com>
Co-authored-by: gravity-wh <114725356+gravity-wh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Jekyll rendering issue on blog homepage Fix Jekyll rendering issue: remove .nojekyll and configure baseurl Oct 10, 2025
Copilot AI requested a review from gravity-wh October 10, 2025 14:59

This branch was successfully deployed

1 active deployment
github-pages — ded68d0e Deployed Oct 10, 2025 by gravity-wh via deploy #3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants