How to have Jekyll blog posts not showing the date? - jekyll

I reedit my posts all the time and the dates don't mean anything so I want to remove them from the posts' titles (not from the titles of the markdown files).

By title I take that you mean the url segments which contain the date + the post title. If so:
you can specify the permalink to Not contain the date on post basis (front matter) like so:
---
title: My new post
permalink: /:title/
---
or if you want this to apply to posts, use it in _config.yml:
permalink: /:title/
There are also other predefined permalinks here, and their components (slugs) can be used in the customization above.

Related

jekyll-seo-tag: Include front matter "tags" property

I'm using jekyll-seo-tag to automatically create meta-tags for my Jekyll blog posts.
Each post on my blog has a tags property in its front matter, which are used in its search system:
---
tags: [how, to, do, this, that, those]
---
I want these tags to be included in the meta-tags of the generated HTML, through jekyll-seo-tag.
How can that be done?

Jekyll Internal Post Links

This is a pretty niche problem, but... I run a blog that runs on Jekyll and I post very regularly. To keep my editing sane I regularly archive posts, and those archived posts get a pretty strict structure. But, I go a full year before archiving.
Where this hurts is in links to other posts. I used to be able to absolutely reference the file name (per jekyll markdown internal links), but this appears to be being deprecated:
Deprecation: A call to '{% post_url 2018-09-06-peppermint %}' did not match a post using the new matching method of checking name (path-date-slug) equality. Please make sure that you change this tag to match the post's name exactly.
Now, if I have to include the full path to the file, then when I archive my posts for the year I have to parse all of the posts for the entire year and update any links between them to include the new file path for their archived location, defeating the point of using this tool at all. A direct link to the page would actually be better, given that I change my URL structure less often.
Is there a better solution for internal links that doesn't depend on the file structure, allowing a file to be moved without having to update every link to that file?
Example File structure:
_posts
-2018
-post1
-post2
-etc
-Archive
-2017
-2016
If there's no better answer, I may just have to go back to using absolute external links.
Solution 1. Use your own include
Create an post_url.html file and write this:
{% include post_url.html slug="2018-09-06-peppermint" %}
The include (called post_url.html) should find the post with the right slug and echo the link, like this:
{% assign link = site.posts | where:'slug',include.slug %}
{{ link[0].title }}
Solution 2. Search and replace
You have to parse posts? A simple search and replace on all files, looking for (/2018/ and replace with (/Archive/2018/ should do the trick (if you use markdown links). This should take just a few seconds.

Collection Permalinks using document Front Matter title

I have a bunch of documents in a collection that when developing, are more easily identified by their 'title code' which is why it would be best to use it as their filename (it helps keep a structure and order). Something like this:
_stories
CH1S1.md
CH1S2.md
CH2S1.md
However, for the pretty urls, a slug from the document's title is better. From the docs it seems that just using the :title permalink parameter is exactly what I want, but the output always uses the document's filename (as if it was using :name instead of :title).
Here is my collection definition in _config.yml:
collections:
stories:
output: true
permalink: /:collection/:title/
Of course, in each individual document's Front Matter I am setting the title property, so I am not sure why this is not working.
I am on the latest version of Jekyll.
Try to set the permalink, instead of title, in YAML Front Matter of each file like this:
permalink: /stories/mystory/

Jekyll pagination on multiple pages

I am new to html/css but am attempting to create a blog using Jekyll and this theme I found here https://github.com/rosario/kasper
The homepage index.html has the all the posts in a paginated list. This is cool. However i would like to group my posts into different categories and have an additional page for each group which would have a paginated list of just posts of that groups.
I can create the additional pages but can't get the lists using any sort of variant of the code in index.html but specifying a group.
Is this possible?
There is also another way to do that. Is using Jekyll Collections.
For each collection you can have a _folder containing your markdown files. Then you can call your posts within this folder from whatever page you want.
To do so, you will need to: 1st. add your collections to your _config.yml file:
collections:
example1:
permalink: /example1/:path/
example2:
permalink: /example2/:path/
example3:
permalink: /example3/:path/
2nd. create a folder to each collection, like: _example1, _example2 and _example3
3rd. create a new html file from which you call each collection:
{% for article in site.example1 %} ... {% endfor %}
That's it! I hope to have helped. If I have, please mark this answer as useful. If you need more assistance, feel free to contact me.
You should share your code with your answer if you want a more detailed answer for your question. As far as I understood you are having trouble with creating a list of blog posts that are all same category. If this is correct then you can achieve it by using liquid for loop. If you look into the code on your index.html it has this for loop
{% for post in paginator.posts %}
If you modify it like below
{% for post in site.categories.comedy %}
Where comedy is a category name. This way we access the category within the site object and get all the posts under this category. If you place similar loops on your separate pages while changing the category names you can have different category lists on different pages. Make sure that you correctly input the category names in your post's front matter. If I succeeded in answering your question please mark the answer as correct.

Hide an entry from the TOC (table of contents) in Jekyll

I have a site that has a lot of markdown files sorted into appropriate folders.
Jekyll creates their HTML versions and the TOC (table of contents) automatically.
In the _config.yml file I can rename some folders, rearrange them (e.g., if I don't want them sorted alphabetically).
I went through their documentation (http://jekyllrb.com/docs/home/) and I did not see a way to hide a file/folder from the TOC. I hope I have missed something.
What I want is to hide some folders and files from the TOC, but keep them live so people with the correct URL can still read the articles. As to why - legacy stuff I don't want people to find by themselves, but old links must still work and I must keep the information online.
Thus, I cannot use the published: false approach in the heading of the markdown file itself, as this will bring it offline.
Here is an example of my config file:
"someFolderWithChildren":
title: "Name of my folder"
position: 10
"someFolderWithChildren/child-folder-I-want-hidden":
title: "hidden folder 1"
published: false
visible: false
noToc: true
hidden: true # these did not work (I admit to guessing in frustration a lot)
"someFolderWithChildren/another-folder-I-want-hidden":
title: "hidden folder 2"
position: 8
"someFolderWithChildren/folder-i-want-in-the-toc":
title: "some live folder"
position: 1
"someFolderWithChildren/folder-i-want-in-the-toc/child-folder-i-want live":
title: "yet another live foder"
position: 0
I really hope someone can point me in the right direction.
EDIT: to answer the comment and answer - I do not use posts, I am afraid, I am tied with other types of content. Further digging showed that the TOC tree is actually a custom JS widget and it seems I need to look into the way its data source is generated by the existing plugins. Thank you for your assistance and your time.
Well, depends what you exactly want. If you just want to have a unpaginated list of all your posts (TOC), then you a are fine and that can be done easily. But if you want a paginated list, you might be comfortable with a workaround.
Without paginator
In your index.html modify {% for post in site.posts %} to
{% assign posts = site.posts | where:"hide", "false" %}
{% for post in posts %}
...
and add a entry hide:[true,false] in the yaml-header of your posts. You can work with front matter defaults so you just have to set hide:false in the posts you want to exclude.
With paginator
First of all, up to now (Jekyll 2.5.3) and to my knowledge there is no possibility to filter the output of the paginator without using a plugin. But as far, as i remember things might change in the upcoming versions of jekyll.
I would recommend, to work with a collection of documents for the posts that should not show up. Collections are rendered like posts (if you pass the same layout to the collection), but since the paginator only works on posts your documents (posts) in a separate collection won't show up in the paginated list of posts as rendered by the paginator.
I hope, i could help...
It turned out that the site i had had a custom plugin that goes through all md files, creates a list for the TOC and serializes it to a json file that is then used by a client-side treeview widget (kendo ui, btw) for its data source. So, i ended up with a few lines of ruby code that skipped adding the folders i want hidden to that json.
While that worked for me, i see the idea in the posted answer and it is perhaps the way to go in a more oob scenario.