# Jekyll \<collection\>.title: where is it documented?

**URL:** <https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578>\
**Category:** Help\
**Created:** [October 19, 2021, 4:35am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578 "2021-10-19T04:35:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 19, 2021, 4:35am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/1 "2021-10-19T04:35:20Z")

</div>

The Jekyll tutorial ( [Collections | Jekyll • Simple, blog-aware, static sites](https://jekyllrb.com/docs/step-by-step/09-collections/) ) has:

```auto
collections:
  authors:
    output: true

```

I discovered that the following code snippet:

```auto
    {% for a in site.authors %}
    {{ a.title }}
    {%- endfor -%}

```

shows that `a.title` is either `Jill` or `Ted` (“J” and “T” are upper cases), which come from the names of the files \_authors/jill.md and \_authors/ted.md without .md extension and the first letter upper cased. If the title is defined inside of the file, it uses that instead.

My question is: where is this documented, or where is it coded in the module? I cannot find from the doc on collections ( [Collections | Jekyll • Simple, blog-aware, static sites](https://jekyllrb.com/docs/collections/) ), on variables, etc.

PS: I assume the same feature can be achieved using categories in the front matter of the posts, which can also handle the situation where an article is written by both authors:

```auto
categories:
- jill
- ted

```

Can this be handled by collections? Either collection or category can group a set of posts by a “keyword” and so display them in a separate page, so what are the difference in term of functionalities? Thanks a lot.

---

<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:** [October 19, 2021, 6:08am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/2 "2021-10-19T06:08:56Z")

</div>

I believe that is just the page variable title:

> **[Variables](https://jekyllrb.com/docs/variables/#page-variables)**
>
> Jekyll traverses your site looking for files to process. Any files with front matter are subject to processing. For each of these files, Jekyll makes a variety of data available via Liquid. The following is a reference of the available data.

which is either the filename without the extension or the title from the frontmatter if set.

Categories and Tags have special meaning when used with posts only - I would avoid using them anywhere else as it can be confusing - though I think they both will work as normal front matter variables - you just won’t get the special things that you get if it is on a post.

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [October 19, 2021, 6:19am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/3 "2021-10-19T06:19:17Z")

</div>

In the example your shared, it’s not actually `a.title` but `a.name`. You will see that `jill.md` has YAML front matter with some data in it, specifically a `name` of `Jill Smith`. That is where the capital “J” Jill is coming from.

At the top of many Jekyll files you will see YAML front matter, like the one in the example:

```auto
---
short_name: jill
name: Jill Smith
position: Chief Editor
---
Jill is an avid fruit grower based in the south of France.

```

All the thing between the set of three dashes are data you can filter on or display on a page.

Here are some videos I created that walk you through how to use data and variables in Jekyll. I suggest you take a look at these and it might help clear things up a little.

Working with Jekyll Data: Part 1 (slides only)

[![](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/e/ebcebdc7ddbf27f2c81dab4c3acc4c0cb6131624.jpeg "Working with Jekyll Data: Part 1 (slides only)") ](https://www.youtube.com/watch?v=7Jj-KX40iTE)

Working with Jekyll Data Part 2: Built-in data

[![](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/2/2cb06d42e8298ce63d76e3ee7ec9c6a93fb8a497.jpeg "Working with Jekyll Data Part 2: Built-in data") ](https://www.youtube.com/watch?v=d9obuvg3ReA)

Working with Jekyll Data, Part 3: Custom Data

[![](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/0/0f3638ad095a50c603656af414a13b7715fba1b0.jpeg "Working with Jekyll Data, Part 3: Custom Data") ](https://www.youtube.com/watch?v=kKU-lMv5OZM)

---

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 19, 2021, 3:02pm UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/4 "2021-10-19T15:02:59Z")

</div>

rdyar: Thanks for the answer! When when I insert the code snippet in the main index.html:

```auto
---
layout: default
title: Home
---

<h1>{{ "Hello World!" | downcase }}</h1>

{% for a in site.authors %}
{{ a.title }}
{{ page.title }}
{%- endfor -%}

```

The `a.title` shows the `Jill` or `Ted` (when no title is defined in author page jill.md and ted.md) while `page.title` shows `Home` in both loops. So `a.title` is not the “page title” of the page rendered by the index.html, but the “page title” of the invisible author “subpage”.

Is it the only way to define an element of a collection by creating a .md file in collection directory? In the introduction, it is:

```auto
_authors/jill.md
_authors/ted.md

```

I see two problems in this. One is the repetitiveness (imagine there are ten authors) , and the other is lack of order. I would like to set up a ordered collection in json file authors.json like:

```auto
- author: ted
  name: Ted Doe
  ...
- author: jill
  name: Jill Smith
  ...

```

Is this possible? If so, how do I tell Jekyll that this json file define my collection, and where is it documented?

PS: I use `a.title` to get each element of the collection to build a navigation, but I do not have control of my own order the way it is setup in the example (jill.md and ted.md).

---

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 19, 2021, 3:09pm UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/5 "2021-10-19T15:09:28Z")

</div>

Bill: both `a.title` and `a.name` exist. `a.title` is Jill or Ted, the name of the .md file leaving out the extension with first letter upper cased (when title is not defined in the front matter), and `a.name` is defined by the front matter as you said correctly (Jill Smith and Ted Doe in the example).

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [October 19, 2021, 3:31pm UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/6 "2021-10-19T15:31:49Z")

</div>

Maybe I am misunderstanding your question then. Could you clarify what you are trying to understand with a little more detail?

---

<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:** [October 19, 2021, 7:12pm UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/7 "2021-10-19T19:12:21Z")

</div>

I think when I say it is the same as page title I mean conceptually - I _think_ it is doing the same thing as page title but as you say if you embed the collection loop in another page then page.title is THAT PAGE’s title, not the title for the collection item. But within the collection loop, title is acting the same way just on the collection item. So if title is in the collection front matter you will get that, otherwise you get the filename without the extension and maybe capitalized?

A collection is really like a post - to be more precise, a post is a form of a collection but with extra stuff added (cats and tags) and extra stuff required (file name convention).

A collection item would normally be something with a fair amount of data - like a post has, possibly using markdown. If all you need is a couple things per data item then you would be better off (?) using a data file like a json file or csv. Another example of a good collection item would be a product - with a summary and description and lots of front matter variables. The authors example is also good and would allow each author to have their own page.

A benefit of a collection over a data file is each collection item can be output as a file/page - so each product (or author) could get its own page. You could have a list of products/authors in a data file but you would only be able to output them in a page by looping over them in that page.

> [@puravidajekyll](#):
>
> Is it the only way to define an element of a collection by creating a .md file in collection directory?

A collection item can have any number of front matter variables, the name of the file or title is just one of them.

> [@puravidajekyll](#):
>
> I would like to set up a ordered collection in json file authors.json like:

data files and collections are 2 different things - your use case would determine which is best. Sometimes they could be used together but probably not normally. Your json example would be fine as a data file, no collection needed.

---

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 20, 2021, 5:23am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/8 "2021-10-20T05:23:51Z")

</div>

Bill: Here is the clarification for my question.

In the Jekyll’s tutorial on collections ( [Collections | Jekyll • Simple, blog-aware, static sites](https://jekyllrb.com/docs/step-by-step/09-collections/) ), we have an authors collection:

```auto
collections:
  authors:

```

and the members of the collection are defined in:

```auto
_authors/xted.md (I renamed ted.md to xted.md)
_authors/jill.md

```

I put the following snippet of code in index.html:

```auto
    {% for a in site.authors %}
    {{ a.title }}
    {%- endfor -%}

```

and discovered that a.title is either Jill or Xted, which is the basename of the .md file that define the authors with the first letter capitalized (title is not defined in the front matter in the example). My question is where this empirically discovered fact is documented.

This is different from a page property in that a page does not have title property if it is not defined in front matter while a member of a collection does; and a a member of a collection does not have a `name` property if it is not defined in front matter while a page does which is the full name of file that renders the page (for example, index.html).

---

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 20, 2021, 5:44am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/9 "2021-10-20T05:44:23Z")

</div>

rdyar: the behavior of the `title` and `name` attributes are different for a member of a collection and a page which is summarized in the following table - suppose neither of them are defined in front matter.

| | member of collection | page |
| --- | --- | --- |
| `title` | basename title cased (“Jill”) | NONE |
| `name` | NONE | fullname without change (“index.html”) |

From this I would conclude that a member of a collection and a page does not share similarities. I loop through a connection and use title to find its members, but I can use other method if there is a better way. Thanks.

---

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [October 20, 2021, 10:21am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/10 "2021-10-20T10:21:20Z")

</div>

Hello @puravidajekyll  
Interesting topic of discussion here.

I’d like to chime in with the following:

- Members of a collection are either _documents_ or _static files_ based on whether they have front matter at the beginning of file content.
- Collection named “posts” is a special entity for Jekyll. It is hard-coded, or baked into Jekyll, and therefore always present. Its members are technically _documents_ but colloquially called _posts_. For backwards-compatibility, it ended up being significantly inconsistent with user-defined collections. ([Details](https://github.com/jekyll/jekyll/issues/7296)).
- _Documents_ are inherently different from _Pages_ (members of `{{ site.pages }}`) with very little parity between them.

Coming to the main topic of this thread: `<collection>.title`…  
Technically, you’re referring to `<collection>.<item>.title`. and it is _equivalent_ to `document.data["title"]`.

Depending on _the context of usage_, it can also be equivalent to `{{ page.title }}`.  
In Liquid templates, `{{ page }}` always refers to the current _view_ being rendered **irrespective of** whether the _view_ is a member of `site.pages` or `site.<collection>`.  
Therefore, when rendering, `/authors/jack.html`, (dedicated page for author _Jack_),  
`{{ page.title }}` will output whatever is stored as `data["title"]` for the _document_ `_authors/jack.md`.

(_Yes, the basename of the document is the default title. Very much like how a “post” `_posts/2021-10-20-hello-world.md` would have a default title of `Hello World`._ It however, isn’t explicitly documented anywhere.)

---

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 21, 2021, 1:19am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/11 "2021-10-21T01:19:53Z")

</div>

When `jill.md` and `ted.md` are converted to html files, `<title>...</title>` was added in the header as meta data. However not all meta data are exposed, and what are exposed may not be in the meta data.

---

<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:** [October 21, 2021, 3:10am UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/12 "2021-10-21T03:10:41Z")

</div>

What metadata are you referring to? in general jekyll doesn’t do anything with the metadata - that is up to you to do in the layout or there is an seo plugin I think a lot of people use.

Jekyll does very little if anything by default, but you can do a lot on your own via includes or layouts.

---

<div class="post-metadata">

**Author:** ![puravidajekyll](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@puravidajekyll](https://talk.jekyllrb.com/u/puravidajekyll)\
**Post date:** [October 21, 2021, 1:21pm UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/13 "2021-10-21T13:21:30Z")

</div>

By “metadata”, I mean the following:

```auto
  <head>
    <meta charset="utf-8">
    <title>Ted</title>

```

which is ted.html converted from ted.md. There is no “metadata” in index.html but yet page.name is exposed. So there is no reliable relationship between the “metadata” and Jekyll exposed variables, just some hint.

---

<div class="post-metadata">

**Author:** ![ashmaroli](https://avatars.discourse-cdn.com/v4/letter/a/df705f/32.png) [@ashmaroli](https://talk.jekyllrb.com/u/ashmaroli)\
**Post date:** [October 21, 2021, 2:37pm UTC](https://talk.jekyllrb.com/t/jekyll-collection-title-where-is-it-documented/6578/14 "2021-10-21T14:37:03Z")

</div>

It comes from the page’s layout. Refer: [Layouts | Jekyll • Simple, blog-aware, static sites](https://jekyllrb.com/docs/step-by-step/04-layouts/#creating-a-layout)
