github - Jekyll/Github 站点没有在 Github 上显示正确的示例博客文章
问题描述
我正在使用 GitHub Desktop 运行 Windows 10。我安装了 Jekyll 并尝试创建一个测试博客。
我从以下说明开始:
- 我在 GitHub Desktop 中创建了存储库,并立即将其发布到 Github.com。
- 当我使用上面链接中提到的 GitHub Desktop “在 bash 中打开”时,我被发送到:
E:\codingPractice\DocSourceBlog\DocSourceBlog>
- 按照上面链接中的建议,我输入:
E:\codingPractice\DocSourceBlog\DocSourceBlog>mkdir docs
E:\codingPractice\DocSourceBlog\DocSourceBlog>cd docs
E:\codingPractice\DocSourceBlog\DocSourceBlog\docs>git checkout --orphan gh-pages
- 我进入
$ jekyll new .
,我得到
New jekyll site installed in E:/codingPractice/DocSourceBlog/DocSourceBlog/docs.
我编辑 gemfile,注释掉“gem jekyll”并
gem "github-pages", "~> 214", group: :jekyll_plugins
通过将当前版本号替换为上述链接的样板来更改下一行。我运行
bundle update
localhostbundle exec jekyll serve
:4000 显示预期的站点,包括一个示例博客文章,可以通过单击“欢迎 Jekyll!”访问该文章。该示例博客文章的开头是:
你会在你的 _posts 目录中找到这篇文章。继续编辑它并重新构建站点以查看您的更改。您可以通过许多不同的方式重建网站,
我使用 GitHub Desktop 将更改的文件提交到分支并将分支发布到 GitHub。
我参考以下说明:
我去 github.com/longarchivist/DocSourceBlog/settings/pages 并将源设置为“gh-pages”和“docs”
我去https://longarchivist.github.io/DocSourceBlog/并看到一些内容在那里,但博客文章似乎没有按预期显示在“欢迎来到 Jekyll!” 我点击链接并到达
https://longarchivist.github.io/jekyll/update/2021/04/18/welcome-to-jekyll.html
但那有404页。
我检查了 github Web 界面以确保存在“_posts”目录。
我注意到“欢迎来到杰基尔!”的地址。链接是:
http://localhost:4000/jekyll/update/2021/04/18/welcome-to-jekyll.html
我可以推测,当我尝试时,ruby 以某种方式破坏了正确的 Jekyll 配置,bundle exec jekyll serve
但如果这足以破坏系统,那么文档似乎具有严重的误导性。
- 我尝试编辑配置文件。“baseurl”变量现在是“/docs”,链接地址是
https://longarchivist.github.io/docs/jekyll/update/2021/04/18/welcome-to-jekyll.html
但是,所需的示例博客文章仍然不显示。反而
https://longarchivist.github.io/docs/jekyll/update/2021/04/18/welcome-to-jekyll.html
仍然是404页面。
所以localhost问题不是问题的关键。
任何建设性的批评将不胜感激。
解决方案
最好的方法似乎是首先启动一个必须包含您的用户名的根目录,然后为每个项目启动一个单独的项目目录。
创建项目目录后,使用“jekyll build”自动生成 Jekyll 站点。在帖子目录中手动添加帖子:不知何故,索引会自动找到它们。然后返回根站点并手动添加指向您的项目目录的链接。例如:
https://longarchivist.github.io/
链接到
https://longarchivist.github.io/codediary/
目前有两个职位。我通过复制原件然后重命名它来创建第二个帖子。Jekyll 显然希望帖子文件名具有正确的日期和月份,因此当我将来使用这种策略时,我将不得不手动更新它们。
推荐阅读
- c# - 为 JWT 的 AsymmetricSecurityKey 交换 SymmetricSecurityKey
- javascript - 压缩多个 PDF 并下载 zip 文件?
- javascript - Chrome Devtools 时间轴中资产的不同颜色深浅意味着什么?
- javascript - 尝试创建 javascript 以用破折号分隔 +1 10 位全球数字
- reactjs - 反应组件子不渲染
- winapi - x86 程序集中的 MessageBox 程序
- python - 如何在 xlsxwriter 中填充一块单元格?
- bash - 输出字段分隔符不一致
- python - 从 PySpark 写入的表中读取时,MySQL 表定义已更改错误
- javascript - 解决矩形和圆形之间的冲突