Jekyll is not correctly reading page title - jekyll

I'm running into a new error after updating to the newest version of Jekyll, where it's giving me an
Here is part of the error message after running jekyll build:
___________________________________________________________________________
| Maruku tells you:
+---------------------------------------------------------------------------
| Bad block-level HTML:
| |#<MaRuKu::Exception: Error: Malformed: tag <p> closes <a>
| |HTML READER
| | state=inside_element match="</p>"
| |Tag stack = ["ul", "li", "a"]
| |Before:
| ||<ul class="compact recent">
| ||<li>
| || <a href="/blog/hello-world.html" title="<p>Hello everyone—just getting the website set up, so it might take a while for more to appear here.</p>
| |After:
| ||">Hello world!</a>
The post in question consists of:
---
layout: blog-post
title: "Hello world!"
published: true
---
Hello everyone---just getting the website set up, so it might take a while for more to appear here.
Check back later for information about my research, papers, etc.
While the page running into the error is using:
<ul class="compact recent">
{% for post in site.categories.blog limit:3 %}
<li>
{{ post.title }}
<span class="date">{{ post.date | date_to_string }}</span>
</li>
{% endfor %}
</ul>
Any ideas as to why it isn't getting the title properly? This worked fine in an earlier version of jekyll.

Removing the title attribute, and making sure the posted code block was separated by the previous text by an empty line, fixed this problem.

Related

Excluding a "spook" pages from <marquee> line made from Jekyll list of page

I am using the following expression
<ul>
{% assign mypages = site.pages | sort: "order" %}
{% for page in mypages %}
<li class="intro">
<a href="{{ page.url | absolute_url }}">{{
page.title }}</a>
</li>
{% endfor %}
</ul>
at my site's index.md to generate list of all pages and all works perfect
Also I am using modified version of the above-mentioned code
<marquee behavior="scroll" scrollamount="17"
direction="left" height="80px" loop="-1"
style="border:0px" width="99%" padding="0px"
onmouseover="this.stop();"
onmouseout="this.start();">
{% assign mypages = site.pages | sort: "order" %}
{% for page in mypages %}
<a href="{{page.url|absolute_url}}"> {{
page.shortname }} <span class="rate">{% include
indexmod.html %}</a></span> <span class="rex"> |
</span> {% endfor %}
</marquee>
to generate Bloomberg-like scroll marquee area made from some meta data and rating value (include indexmod.html), but there are appearing 7 "spook" pages without title and linking to: 404.html, feed.xml, sitemap.xml, robots.txt, redirects.json, style.css...
I have try to add thouse pages into ignore list in _config.yml
Thanks in advance for trick how to add all of them into some exclude filter.
Here is screen of the mentioned marquee on my site. Topic 032C 0.24 is linking to a real article with title "032C" with rate 0.24, next topic is wrong and linking to 404.html with rating 0.0, next topic is good again 4S4R, and all rest zeros are titles empty rates for technical files of my site. I have left only 2 real articles on my site for easier fixing the glitch.
I see there is no any comments. I have fixed part of problem using exclude line in front matter for 404.md. But still have question about other 5 files with extensions .css .json .xml .txt.
Therefore I am redirecting rest of question to a new topic

Jekyll - How do you get rendered content of posts?

I need to get the rendered content (without html tags) of some posts in Jekyll. When I do 'post.content' It returns the full HTML instead of the rendered text. How do I do this?
You can use strip_html filter {{ post.content | strip_html }}

Jekyll Tagging - Output tags as pages

I'm trying to output tags as pages from collection items/posts, so if a user clicks on a tag it will take them to a page where I can set the layout to display all items with that specific tag.
I've been trying to use the jekyll-tagging plugin but haven't had much luck. I've tried the following.
This generates all tags within the site as links that lead to a page.
{{ site | tag_cloud }}
This generates the same as above
{{ page | tag_cloud }}
This generates all tags within the page as links but they don't output as pages and I can't figure out how to do this.
{{ page | tags }}
Am I missing something that will output the tags as pages as {{ site | tag_cloud }} does?
Thanks!
To use jekyll-tagging you need to configure it, in _config.yml add:
tag_page_layout: tag_page
tag_page_dir: tag
Then in _layouts/ folder create the file tag_page.html:
---
layout: default
---
<h2>{{ page.tag }}</h2>
<ul>
{% for post in page.posts %}
<li>{{ post.title }} ({{ post.date | date_to_string }} | Tags: {{ post | tags }})</li>
{% endfor %}
</ul>
<div id="tag-cloud">
{{ site | tag_cloud }}
</div>
Then tag pages will be generated in the folder _site/tag and tag filters will generate links to them.

How can I replace the last <p> tag in Jekyll

In my index.html page, I want to append '...' after the post.excerpt. The idealized way is to use code {{ post.excerpt |replace_last:'</p>', '……</p>' }},but the filter replace_last seems not defined. So how can I do this in jekyll? thank you.
In my opinion, a better way is CSS:
.excerpt p:last-child::after {
content: '..';
}
This adds ".." to the last paragraph's after psuedo-element inside the excerpt div.
<div class="excerpt">
<p>Normal paragraph.</p>
<p>Paragraph with trailing ellipsis.</p>
</div>
If you need to do it with Jekyll, you could use the slice filter to cut off the trailing </p> and the append filter to add '...</p>' to the end. This will not work if your excerpt does not end with a paragraph.
I prefer to strip the p tags from post.excerpt first, then append '...'.
This way, we can even add "read more" link inside of the p.
<p>
{{ post.excerpt | strip_html | append: "..." }}
{% if post.excerpt != post.content %}
>>
{% endif %}
</p>
I've found a workaround for this to achieve an ellipsis with a "Read More" link. Both the truncate filter and setting excerpt_separator have shortcomings, however, it's simple to do implement it yourself via split. Use this in your index.html where you iterate the posts:
{{ post.content | split:'<!--read more-->' | first | append: "…"}} Read more
And you just have to place <!--read more--> wherever in your blog post where you want it to cut off and be replaced by a "… Read More" link.

Jekyll - display a random chosen post in index

I would like to display a randomly chosen post in the front page of my Jekyll site.
Do you have any idea how I could loop and chose a random post each time the page is loaded ?
This is the index that I have at the moment.
---
layout: default
title: Home
---
<h1 class="content-listing-header sans">Posts</h1>
<ul class="content">
{% for post in site.posts %}
<li class="listing">
<hr class="slender">
<h4 class="contrast">{{ post.title }}</h4>
<span class="smaller">{{ post.date | date: "%B %-d, %Y" }}</span> <br/>
<div>{{ post.excerpt }}</div>
</li>
{% endfor %}
Thanks
Jekyll generates static files. You can chose a random post to be inserted in your home page, but this page will be static and random post will only be changed when you site is generated.
{% assign random = site.time | date: "%s%N" | modulo: site.posts.size %}
<h1>{{ site.posts[random].title }}</h1>
As liquid has no random tag, you can mimic randomness based on time.
See https://stackoverflow.com/a/28323813/1548376
The only way to load a different post on each reload is to do it with javascript. And here it will become complicated.
you will need to create a posts list for javascript to choose from,
you will have to generate specific page for each post with only post's html in it. No head, navigation and so on. And this can only be accomplished with a Jekyll generator plugin.