Reputation: 335
I follow the official guide of Collections | Jekyll • Simple, blog-aware, static sites to add collections to my blog wow-yes.github.io.
I have added the staff_members
into _config.yml
. All sources are stored in GitHub - wow-yes/blog: my personal blog.
collections:
my_collection:
output: true
staff_members:
output: true
people: true
and I also add the jane.md
into the folder _staff_members
.
When I tested it in my local pc, everything is ok. http://127.0.0.1:4000/staff_members/jane.html works well.
But when I open the https://wow-yes.github.io/staff_members/jane.html on github page, I get a 404 page Site not found · GitHub Pages
It looks like that Github didn't compile the jane.md
.
Thanks.
Upvotes: 1
Views: 495
Reputation: 335
I have solved this question by myself.
This link https://wow-yes.github.io/staff_members/jane.html is wrong. The right one is https://wow-yes.github.io/blog/staff_members/jane.html. Github has compile jane.md
but I didn't get the right link.
The /blog/
is missing on github-pages address. Well, so I add {{site.baseurl}}
into _layout/collections.html
to generate the right url for my collection. It works well on my local server and github-pages.
The official guide Collections | Jekyll • Simple, blog-aware, static sites is right on local server. But when you apply this code into github pages, please add {{site.baseurl}}
before {{ staff_member.url }}
. For example:
{% for staff_member in site.staff_members %}
<h2>
<a href="{{ site.baseurl }}{{ staff_member.url }}">
{{ staff_member.name }} - {{ staff_member.position }}
</a>
</h2>
<p>{{ staff_member.content | markdownify }}</p>
{% endfor %}
Upvotes: 2