Long
Long

Reputation: 101

Jekyll/Github site does not show correct sample blog post on Github

I am running Windows 10 with GitHub Desktop. I installed Jekyll and tried to create a test blog.

I started with the instructions at:

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

  1. I created the repository in GitHub Desktop and immediately published it to Github.com.
  2. When I use GitHub Desktop to "open in bash" as mentioned in the link above, I get sent to: E:\codingPractice\DocSourceBlog\DocSourceBlog>
  3. Following the suggestions in the link above, I enter:
E:\codingPractice\DocSourceBlog\DocSourceBlog>mkdir docs

E:\codingPractice\DocSourceBlog\DocSourceBlog>cd docs

E:\codingPractice\DocSourceBlog\DocSourceBlog\docs>git checkout --orphan gh-pages
  1. I enter $ jekyll new . and I get

New jekyll site installed in E:/codingPractice/DocSourceBlog/DocSourceBlog/docs.
  1. I edit the gemfile, comment out the "gem jekyll" and change the next line to gem "github-pages", "~> 214", group: :jekyll_plugins by substituting the current version number into the boilerplate of the above link.

  2. I run bundle update and bundle exec jekyll serve and localhost:4000 shows the expected site, including a sample blog post that can be accessed by clicking "Welcome of Jekyll!" That sample blog post starts off with:

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways,

  1. I use GitHub Desktop to commit the changed files to the branch and publish the branch to GitHub.

  2. I refer to instructions at:

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. I go to github.com/longarchivist/DocSourceBlog/settings/pages and set the source to "gh-pages" and "docs"

  2. I go to https://longarchivist.github.io/DocSourceBlog/ and see that some of the content is there, but the blog post does not seem to show up as expected at "Welcome to Jekyll!" I click the link and get to

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

but that has the 404 page.

  1. I check the github web interface to make sure that the "_posts" directory is there.

  2. I noticed that the address of the "Welcome to Jekyll!" link was:

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

I can speculate that ruby somehow destroyed the correct Jekyll configuration when I tried bundle exec jekyll serve but if that was enough to break the system then the documentation seems to be badly misleading.

  1. I tried editing the config file. The "baseurl" variable is now "/docs" and the link address is

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

However, the desired sample blog post still does not display. Instead

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

is still a 404 page.

So the localhost problem is not the key to the problem.

Any constructive criticisms would be appreciated.

Upvotes: 0

Views: 99

Answers (1)

Long
Long

Reputation: 101

The best way seems to be to start a root directory that must contain your username first, then start a separate project directory for each project.

After creating a project directory, use "jekyll build" to auto-generate a Jekyll site. Add posts manually in the posts directory: somehow the index finds them automatically. Then go back to the root site and manually add a link to your project directory. For example:

https://longarchivist.github.io/

links to

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

which currently has two posts. I created the second post by copying the original, then renaming it. Jekyll apparently expects the post filename to have the correct day and month, so when I use this tactic in the future, I will have to update those manually.

Upvotes: 0

Related Questions