【问题标题】:Jekyll/Github site does not show correct sample blog post on GithubJekyll/Github 站点没有在 Github 上显示正确的示例博客文章
【发布时间】:2021-07-12 23:43:36
【问题描述】:

我正在运行带有 GitHub Desktop 的 Windows 10。我安装了 Jekyll 并尝试创建一个测试博客。

我从以下位置的说明开始:

https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/creating-a-github-pages-site-with-jekyll

  1. 我在 GitHub Desktop 中创建了存储库,并立即将其发布到 Github.com。
  2. 当我使用 GitHub Desktop 以“在 bash 中打开”时,如上面链接中所述,我被发送到: E:\codingPractice\DocSourceBlog\DocSourceBlog>
  3. 按照上面链接中的建议,我输入:
E:\codingPractice\DocSourceBlog\DocSourceBlog>mkdir docs

E:\codingPractice\DocSourceBlog\DocSourceBlog>cd docs

E:\codingPractice\DocSourceBlog\DocSourceBlog\docs>git checkout --orphan gh-pages
  1. 我输入 $ jekyll new .,我得到了

New jekyll site installed in E:/codingPractice/DocSourceBlog/DocSourceBlog/docs.
  1. 我编辑 gemfile,注释掉“gem jekyll”并将下一行更改为 gem "github-pages", "~> 214", group: :jekyll_plugins 通过将当前版本号替换为上述链接的样板。

  2. 我运行 bundle updatebundle exec jekyll serve 和 localhost:4000 显示预期的站点,包括一个示例博客文章,可以通过单击“欢迎 Jekyll!”访问该文章。该示例博客文章的开头是:

你会在你的 _posts 目录中找到这篇文章。继续编辑它并重新构建站点以查看您的更改。您可以通过多种不同方式重建网站,

  1. 我使用 GitHub Desktop 将更改的文件提交到分支,并将分支发布到 GitHub。

  2. 我参考以下说明:

https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#choosing-a-publishing-source

  1. 我去 github.com/longarchivist/DocSourceBlog/settings/pages 并将源设置为“gh-pages”和“docs”

  2. 我转到https://longarchivist.github.io/DocSourceBlog/ 并看到其中的一些内容,但博客文章似乎没有按预期显示在“欢迎来到 Jekyll!”我点击链接进入

https://longarchivist.github.io/jekyll/update/2021/04/18/welcome-to-jekyll.html

但那有 404 页面。

  1. 我检查了 github web 界面以确保“_posts”目录在那里。

  2. 我注意到“Welcome to Jekyll!”的地址。链接是:

http://localhost:4000/jekyll/update/2021/04/18/welcome-to-jekyll.html

我可以推测,当我尝试 bundle exec jekyll serve 时,ruby 以某种方式破坏了正确的 Jekyll 配置,但如果这足以破坏系统,那么文档似乎具有严重的误导性。

  1. 我尝试编辑配置文件。 “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 页面。

所以本地主机问题并不是问题的关键。

我们将不胜感激任何建设性的批评。

【问题讨论】:

    标签: github jekyll


    【解决方案1】:

    最好的方法似乎是首先启动一个必须包含您的用户名的根目录,然后为每个项目启动一个单独的项目目录。

    创建项目目录后,使用“jekyll build”自动生成 Jekyll 站点。在帖子目录中手动添加帖子:索引会以某种方式自动找到它们。 然后返回根站点并手动添加指向您的项目目录的链接。 例如:

    https://longarchivist.github.io/

    链接到

    https://longarchivist.github.io/codediary/

    目前有两个帖子。我通过复制原件然后重命名它来创建第二个帖子。 Jekyll 显然希望帖子文件名具有正确的日期和月份,因此当我将来使用这种策略时,我将不得不手动更新它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-29
      • 2020-08-02
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 2017-11-13
      • 2019-05-17
      相关资源
      最近更新 更多