I have tried this code {{site.categories | inspect}} in default.html, but it returns empty space like this {}.
My post has a front matter that includes categories: apple.
What have I missed?
oh i found..
My jekyll theme post was referenced from 'docs' folder, but jekyll said every posts should be placed in _post folder. so jekyll site variable could not read categories of posts in docs folder.
Related
I'm trying to set up Jekyll based blog posts on my site, but running into trouble styling the URLs how I'd like (<site URL>/blog/<blog title>). Based on the documentation here, I should be able to do this by either doing permalink: none and setting the category to blog or by doing permalink: /:category/:title or permalink: /blog/:title in my _config.yml file, but none of these produces the desired result, with even the none preset just giving me /blog/2022/06/22/<blog title>.html
Any ideas what I'm doing wrong?
As far as I know, there isn't a way to introduce a string in the permalink like that.
However, you can try forcing all your posts to have a category blog thus allowing you do use permalink: /:categories/:title. To do that you can move your posts directory inside a blog directory. That'll tell Jekyll that all posts there are part of the blog category:
$ tree .
├── blog
│ └── _posts
│ └── 2022-06-23-welcome-to-jekyll.markdown
[…]
A problem with that approach is that other category names will appear in the final URL as well. For example, I created a default Jekyll site (with jekyll new test), changed the permalink definition in _config.yml and moved the posts directory like above. The resulting permalink for the default post is:
http://localhost:4000/blog/jekyll/update/welcome-to-jekyll
If you don't care about categories, or if having some posts get extra categories but everything being contained in /blog, this should work.
I'm using Jekyll for my blog. I want to protect some blog post with a password and I've decided to use Staticrypt.
I can encrypt the index.htmlpage of one of my blog post with the Staticryp CLI and my custom password_template.html. It outputs a index_encrypted.html.
My question is: Where do I put the index_encrypted.html? I can't add it to the _site since Jekyll return the build to default everytime I serve it.
I tried adding the index_encrypted.html to the _includes folder and calling the page from the .md post like this:
{% include index_encrypted.html %} but this just break the page.
Thank you!
I figured out how to do it.
Here's what I did:
Put the index_encrypted.html in _includes and _layouts
Add a permalink: /index_encrypted.html in front matter of the .md post you're targetting.
Add a layout: index_encrypted in front matter of the .md post you're targetting.
Delete the whole markdown content of the .md post.
Voila!
You front matter should look like this:
---
title:
date:
tags:
description:
layout: index_encrypted
permalink: "/index_encrypted.html"
---
Edit: Make sure to create a copy of your .md post for later use.
I have a page called blog.md which has some code like this.
permalink: /blog/
layout: collection
collection: blog
entries_layout: grid
classes: wide
Then I have a folder called _blog, with a number of .md files in.
Is there anyway I can add another level of order here and instead of displaying all the _blog .md files on the blog.md page.. I want to add two folders/lists which contain certain .md files.
Any ideas? Thanks
This should work by adding the path to your for loop. For example, let's assume you have a directory in your _blog directory called "orange." So your file path would be _blog/orange. To loop through only the files in the orange directory you could do this:
{% for post in site.blog.orange %}
{{ post.do-stuff }}
{% endfor %}
On a side note, Jekyll is going to look for blog posts in the _posts directory. I assume this _blog directory is a collection, but creating a "blog" collection will make things confusing if anyone else ever needs to touch this codebase.
I have a project where I have posts on main page of the blog and I would love to have another posts folder inside subfolder(s).
I am talking about this structure:
_posts
_posts/2020-04-04-Testmain.md
subpage/_posts
subpage/_posts/2020-04-04-Testsub.md
subpage/index.html
index.html
I can access posts from subpage by using {% for post in site.categories.subpage %} inside subpage/index.html but I can't find a way how to force jekyll to also generate posts in the subpage folder so I can access it at page http://127.0.0.1:4000/subpage/testsub
Is it even possible? Or is it better to follow this structure?
_posts
_posts/2020-04-04-Testmain.md
_posts/subpage
_posts/subpage/2020-04-04-Testsub.md
If so, is there some setting required to make the post at http://127.0.0.1:4000/subpage/testsub ?
Found the solution!
In _config.yml you can use permalink: /:categories/:title
And with following file hierarchy:
_posts
_posts/2020-04-04-Testmain.md
subpage/_posts
subpage/_posts/2020-04-04-Testsub.md
subpage/index.html
index.html
You will get these websites:
http://127.0.0.1:4000/
http://127.0.0.1:4000/subpage/
http://127.0.0.1:4000/subpage/testsub
And you can still access all posts from selected subfolder with {% for post in site.categories.subpage %}
I'm making a website/blog that catalogs DIY projects, currently I have each project as a post, and recent posts are displayed on the home page.
What Im trying to do is have a separate page with project/post categories (projects.html). This page lists a collection of post categories that manually I've made, and will not show any actual posts.
I would then like these categories/collection items to be generated into a page that links to a layout where I can specify a FOR loop that will display each post specific to that category on the page.
I've tried many ways to generate pages from a collection of .md files as jekyll does for posts but I can't get this working. Is this possible to do? or is there a way to automatically generate an html page for every .md file in a folder?
Here is a link to the page I'm working with. http://happy-swallow.cloudvent.net/
Thanks!
You can use Collections and specify to render each file in the collection folder as a page:
tell Jekyll to render individual collection pages, in _config.yml:
collections:
my_collection:
output: true
Then create a folder named _my_collection (the folder name must start with an underscore) and every markdown file inside it will have a single page.