Skip to content

Commit c4241ad

Browse files
committed
feat: Allow empty titles in posts
1 parent 007bbe3 commit c4241ad

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

_layouts/default.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>{% if page.title %}{{ page.title }} – {% endif %}{{ site.name }} – {{ site.description }}</title>
4+
<title>{% if page.title and page.title != "" %}{{ page.title }} – {% endif %}{{ site.name }} – {{ site.description }}</title>
55
{% seo %}
66
{% include meta.html %}
77

_pages/categories.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ title: Categories
1616
<a name="{{ category_name | slugize }}"></a>
1717
{% for post in site.categories[category_name] %}
1818
<article class="archive-item">
19-
<h4><a href="{{ site.baseurl }}{{ post.url }}">{{post.title}}</a></h4>
19+
<h4><a href="{{ site.baseurl }}{{ post.url }}">{% if post.title and post.title != "" %}{{post.title}}{% else %}{{post.excerpt |strip_html}}{%endif%}</a></h4>
2020
</article>
2121
{% endfor %}
2222
</div>

_posts/2019-08-08-no-title-posts.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
layout: post
3+
title: ""
4+
categories: Miscellaneous
5+
---
6+
Sometimes, your post just stands for itself and doesn't need a title. And that's fine, too!

index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<div class="posts">
66
{% for post in paginator.posts %}
77
<article class="post">
8+
<a href="{{ site.baseurl }}{{ post.url }}">
9+
<h1>{{ post.title }}</h1>
810

9-
<h1><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></h1>
10-
11-
<div>
12-
<p class="post_date">{{ post.date | date: "%B %e, %Y" }}</p>
13-
</div>
14-
11+
<div>
12+
<p class="post_date">{{ post.date | date: "%B %e, %Y" }}</p>
13+
</div>
14+
</a>
1515
<div class="entry">
1616
{{ post.excerpt }}
1717
</div>

search.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% for post in site.posts %}
55
{
66

7-
"title" : "{{ post.title | escape }}",
7+
"title" : "{% if post.title != "" %}{{ post.title | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}",
88
"url" : "{{ site.baseurl }}{{ post.url }}",
99
"category" : "{{ post.categories | join: ', '}}",
1010
"date" : "{{ post.date | date: "%B %e, %Y" }}"

0 commit comments

Comments
 (0)