MyBlogContent is a sub folder containing .md files.
Works fine when the .md files are placed in the _post folder.
Used the front matter as "category: MyBlogContent" in the .md file.
How I try to get all posts in MyBlogContent category :
{% for post in site.category.MyBlogContent %}
<li>
{{ post.title }}
</li>
{% endfor %}
site.category key doesn't exist. You must look in site.categories, like this :
{% for post in site.categories.MyBlogContent %}
Related
As mentioned in the Jekyll docs here, I have the following in my _config.yml as:
collections:
sections:
order:
- introduction.md
- battery-state.md
- vibe.md
- references.md
To render the content of each file within the HTML, I have the following:
{% for section in site.sections %}
{{ section.content }}
{% endfor %}
However, the content order is not presented as what I defined in the config file. How do I display the content in the order I defined in the config file?
Manually ordering documents in a collection was introduced in Jekyll 4.0
To use this feature, make sure that you're using Jekyll 4.0
For a site deployed on GitHub Pages, that would mean having to build the site outside GitHub Pages environment and upload the contents of the destination directory (_site).
You can also choose to add the sections to the front matter of the page. This is useful when you are not using Jekyll v4 or you want the user to be able to edit the order in CloudCannon, Netlify CMS, Forestry or another CMS with front matter editor.
sections:
- introduction
- battery-state
- vibe
- references
And the use a layout like this:
{% for s in page.sections %}
{% for section in site.sections %}
{% if s == section.slug %}
...
{% endif %}
{% endfor %}
{% endfor %}
I have a Jekyll setup that looks like this:
_config.yml
_records
a.html
b.html
c.html
...
I want to create a home page that links to each record. However, I want to render a.html and b.html to /records/, but I don't want to render c.html to /records/, as that HTML will be provided to my server from a different process altogether.
I tried setting the following in _config.yml:
exclude:
_records/c.html
But this also removes c.html from site.records, which is not what I want. The best solution I have right now is to prevent my deploy script from deploying _site/records/c.html, but I'd much rather prevent _site/records/c.html from being generated in the first place.
Is it possible to include c.html in site.records to create the links on the home page but not render /records/c.html? Any help others can offer with this question would be greatly appreciated!
Here's how I did this. Inside _records/c.html, set in the front matter:
permalink: '_'
route: /records/c.html
That will make it so that we render the page's html content to _site/_.html, a route that won't ever get visited.
Then in index.html to create the link to the route attribute of this page, use:
{% for record in site.records %}
{% if record.route %}
{% assign url = record.route %}
{% else %}
{% assign url = record.url %}
{% endif %}
<a href='{{ url }}'>{{ record.title }}</a>
{% endfor %}
I'm not sure what I've done. I've added some new pages from my collections folders.
The folders and files are created in the site folder.
However I can iterate my collections and see the links, however the links provide 404 errors as the files aren't being created.
I've re-saved the files as utf8 but this didn't hel, mentioned in a related question.
I've even removed all the files and put back the original test files which did work previously.
Foolishly I didn't have the project under source control.
Obviously jekyll can see them and read their contents and the loops work...
But the files aren't being generated.
<h3>User Guides</h3>
{% for user in site.stt_userguides %}
{::nomarkdown}
<a href="{{ user.url }}">
<h3>{{ user.title }}</h3>
</a>
<p>{{ user.content | markdownify }}</p>
{:/}
{% endfor %}
<h3>Features</h3>
{% for user in site.stt_features %}
{::nomarkdown}
<a href="{{ user.url }}">
<h3>{{ user.title }}</h3>
</a>
<p>{{ user.content | markdownify }}</p>
{:/}
{% endfor %}
I'm using this command ...
bundle exec jekyll serve
It confirms the files aren't found.
Due to initial configuration issues implementing collections, I had inadvertently removed the output: true setting, also useful to add the permalink property under your collection in config.yml.
As shown in the collections section on this page https://jekyllrb.com/docs/permalinks/
I am using Jekyll to build a web site,
I want to have some folder structure like
root
- _posts
Kinds of MD files
Index.html
- v1.0
- _posts
Kinds of MD files
Index.html
I want to build a web site, the URL like http://host/root/ points to current version document,the URL like http://host/root/v1.0 points to version 1.0 document.
In both index.html, I use code like below,
{% assign sortedCategories = site.categories | sort %}
{% for category in sortedCategories %}
<h1 class="post-title" id="{{ category[1] | replace:' ','-' | replace:'.','' }}">{{ category[1] | join: "/" | upcase }}</h1>
<ul class="post-list">
{% for posts in category %}
{% for post in posts reversed %}
{% if post.title != null%}
<li>
<h2 class="post-title" id="{{ post.id | remove_first:'/'}}">{{ post.title }}</h2>
<article class="post-content">
{{ post.content }}
</article>
</li>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
{% endfor %}
The issues I met is,
As both _post folder has similar posts and category, in the http://host/root/, each post is shown twice.
In URL http://host/root/, it has an additional category which contains all the posts (in both folder _posts and v1.0/posts)
The same issues for URL http://host/root/v1.0
I want to know how I can restrict the site.categories to only search specified folder? Or there is some other suggestions on this?
thanks
posts can not be limited to a particular folder as it is site wide. You can create custom collection. Suppose if you have v1, v2 and root(pointing to v2). You can use the same collection name for v2 and root.
As mentioned by #ganesshkumar, use jekyll collections for this
How can I use the include_relative tag correctly?
I have my folder layout and files like so.
my-account.html
_includes
page-content
my-account
my-account.html
header.html
nav.html
In my-account.html I include the following file.
{% include page-content/my-account/my-account.html %}
All good.
However, inside the my-account.html from the includes folder, I am also calling header.html and nav.html
{% include page-content/my-account/header.html %}
{% include page-content/my-account/nav.html %}
Is there a way to use include_relative like this from the my-account.html since its in the same folder?
{% include_relative header.html %}
{% include_relative nav.html %}
Currently I get the error:
'./header.html' not found, so obviously the include_relative is not working.
Thanks!
Try this to the file my-account.html:
{% include /page-content/my-account/header.html %}
{% include /page-content/my-account/nav.html %}
I've tested here with a similar structure and worked, then you should be ok. ;)