# SOLVED: Liquid Exception: undefined method \`split' for nil:NilClass in /\_layouts/post.html

**URL:** <https://talk.jekyllrb.com/t/solved-liquid-exception-undefined-method-split-for-nil-nilclass-in-layouts-post-html/8302>\
**Category:** Help\
**Created:** [June 7, 2023, 5:11pm UTC](https://talk.jekyllrb.com/t/solved-liquid-exception-undefined-method-split-for-nil-nilclass-in-layouts-post-html/8302 "2023-06-07T17:11:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![verity](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/verity/32/5365_2.png) [@verity](https://talk.jekyllrb.com/u/verity)\
**Post date:** [June 7, 2023, 5:11pm UTC](https://talk.jekyllrb.com/t/solved-liquid-exception-undefined-method-split-for-nil-nilclass-in-layouts-post-html/8302/1 "2023-06-07T17:11:22Z")

</div>

My public repository: [GitHub - verity-s/verity-s.github.io: Enables / disables WiFi networks on T-Mobile home internet Arcadyan KVD21 gateway](https://github.com/verity-s/verity-s.github.io)

Build fails with this error, and I have no idea what is going on. The post.html contents:

```auto
---
layout: base
---

<section>
  <br />
  {{ content }}  
  <h1>
    Latest posts
  </h1>
  <ul>
    {% for post in site.posts %}
      <h2><a href="{{ post.url }}">{{ post.title | escape }}</a>
      </h2>
      <h6>
      <span>
        {{ post.date | date_to_string }} &bull;
        {% assign words = post.content | number_of_words %}
        {% if words < 360 %}
          1 min read
        {% else %}
          {{ words | divided_by:180 }} min read
        {% endif %}
      </span>
      </h6>
      {{ post.excerpt }}
    {% endfor %}
  </ul>
</section>

```

I further edited the post.html to try and change the post date format to YYYY-MM-DD, adding to \_config.yml:  
`date_format: "%Y-%m-%d"`  
And then I hope to have in post.html:  
`{{ post.date | date: site.date_format | date_to_string }} &bull;`  
But no, same exact Liquid error. Any guidance is appreciated!

---

<div class="post-metadata">

**Author:** ![verity](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/verity/32/5365_2.png) [@verity](https://talk.jekyllrb.com/u/verity)\
**Post date:** [June 7, 2023, 9:14pm UTC](https://talk.jekyllrb.com/t/solved-liquid-exception-undefined-method-split-for-nil-nilclass-in-layouts-post-html/8302/2 "2023-06-07T21:14:26Z")

</div>

It feels like it took me forever to have a lightbulb moment about this. To any other beginner in the future: inside a `post.html`, the post date is `page.date` (and similarly, it’s `page.content` and so on) but inside my `default.html` list of posts and their dates are `post.date` (and correspondingly `post.content`). I was missing that distinction and the build was not finding the correct values. Pfew.

Still not sure what the logic is of this difference.

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [June 8, 2023, 3:17pm UTC](https://talk.jekyllrb.com/t/solved-liquid-exception-undefined-method-split-for-nil-nilclass-in-layouts-post-html/8302/3 "2023-06-08T15:17:32Z")

</div>

> [@verity](#):
>
> `{% for post in site.posts %}`

when you loop over things you can use any word/string as the item descriptor (not sure what this is actually called - iterator maybe) so in your code above it says `for post in..` the `post` can be whatever you want, normally people use a word that descibes what the thing is (a post) - I usually use item - like `for item in site.posts` and then it is `item.title` or whatever.

When you you are on a page and not in a loop then you use page - like `page.title`.

I had the same issue originally thinking post.whatever was a thing when it isn’t - unless you are inside a loop and it said `for post in.....`

---

<div class="post-metadata">

**Author:** ![verity](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/verity/32/5365_2.png) [@verity](https://talk.jekyllrb.com/u/verity)\
**Post date:** [June 8, 2023, 5:08pm UTC](https://talk.jekyllrb.com/t/solved-liquid-exception-undefined-method-split-for-nil-nilclass-in-layouts-post-html/8302/4 "2023-06-08T17:08:54Z")

</div>

Thank you, that is very helpful!
