Github-pages docs _posts cannot be reached


#1

Hello,

This is a question regarding jekyll and its use in github-pages.

From github, I created a docs folder in the project repository and set the github setting to publish with master docs.

Then I did a jekyll new . to create the default files in the docs directory, and I added the gem githubs-page and modified Gemfile according to the jekyllrb docs github-pages . I then did a jekyll build and bundle exec jekyll serve and looked at localhost:4000 in my browser, everything looked fine, include in the feed.xml that shows the posts, that is, I could click through to the posts. I went on to commit and push my changes to github and looked at my github_dot_io project page (link below).

The style didn’t match (minima), and although I can see the posts being enumerated (posts which I added to the docs _posts directory, I cannot actually access them in github_dot_io as in my local jekyll build - serve.

I am suspecting that I don’t understand how jekyll references the _posts directory under a project page. _posts works fine in my github-pages user page, but not if it is part of a sub-directory for a particular project.

The instructions in jekyllrb docs github-pages do say that the project URL gets complicated, but I am not referring directly to the _posts directory, rather the jekyll-feed plugin seems to be doing most of this referencing. Looking at my local index.html, it does point to /category/date/topic entries, for my individual posts, I wonder if the relative path is not being respected in my github-pages, I did a quick diff between the index.html in my local directory and the one generated by github-pages the only difference is the following:

link rel=“canonical” href=“http: slash slash localhost:4000/” <- local
(sorry for the slash, I can only have two links in my post)

link rel=“canonical” href="/" <- github io

This seems to be valid to me, perhaps I don’t understand how github-pages is running jekyll, or whether each project is treated on its own (as in being allowed to have its own _posts), or whether there is some dependency between the user page and the individual project pages, or how the server treats relative paths.

For reference, my setup is at https://github.com/frankieliu/pgm/tree/master/docs and the corresponding github-page at https://frankieliu.github.io/pgm

Thank you. -f


#2

Your issue here is that you have not configured the baseurl setting properly. When setting up for GitHub Pages docs, you need to set baseurl: /<REPO-NAME>. In your case, it would be:

baseurl: "/pgm"

Setting that should resolve the CSS and links to your posts just fine…


#3

Thank you @ashmaroli that did the trick.

When serving locally, after the suggested change in _config.yml , I use

bundle exec jekyll serve --baseurl “”

to see it in localhost:4000

Is there a better way of doing this?

Thanks again.


#4

Either that or do a regular bundle exec jekyll serve and access your site at http://localhost:4000/pgm


#5

Great, thanks for the alternate solution.

–edit: @ashmaroli : your suggestion in

doesn’t work, note I did a build followed by a serve, and pointed to localhost:4000/pgm

–edit:
There is a missing / at the end, then it works: http://localhost:4000/pgm/

Also I found this post which contains more information:


#6

Ah right! my bad… Thanks for the correction! :smiley: