Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The difference between data.content and templateContent #882

Closed
pepelsbey opened this issue Jan 24, 2020 · 4 comments
Closed

The difference between data.content and templateContent #882

pepelsbey opened this issue Jan 24, 2020 · 4 comments

Comments

@pepelsbey
Copy link

pepelsbey commented Jan 24, 2020

I have a collection of pages grouped by tags: episode. When I cycle through such collection using {%- for episode in collections.episode -%} I can easily get front matter data by episode.date for example. When I need the actual content of a page, I use episode.data.content. I’m not sure where it came from, I can’t find it on docs, but it used to work.

Today I realized that it doesn’t work anymore and {{ episode.data.content }} returns nothing. I found templateContent and it worked just like data.content used to work before.

The weird thing is that data.content still works it one project, but stopped working on the other, so I had to replace it with templateContent. Both of the projects use the latest 0.10.0 and I have no idea what’s going on :)

I’m glad I (kind of) figured out how to make it work. But here are my questions:

  1. What is data.content, where it’s documented, why it’s not always available?
  2. What’s the difference between data.content and templateContent?

Thank you 🌲

@jameshfisher
Copy link

I have the same question. From experimentation, it seems collection items have an item.templateContent, but not a item.content. But from a layout, the page has a data.content.

@jtlapp
Copy link

jtlapp commented Oct 29, 2022

If this is intentional, it really ought to be in the docs. I just spent an hour and a half trying to figure out why data.content wasn't working on items of a paginated collection. This thread told me the solution.

UPDATE: It seems that item.templateContent always works, so I'm dropping use of item.data.content.

@uncenter
Copy link
Contributor

Seeing as content is supposedly an alias of templateContent for collection data I'm surprised that that apparently isn't the case for other places where templateContent exists. I'd say this is less of a education and more of a change that would involve deprecating templateContent in v3 and ensuring that content works in all places templateContent does.

@zachleat
Copy link
Member

Related to #338, content is the thing starting in 2.0+ (via #2695) per the docs link in #882 (comment)

It’s unlikely that we’ll remove templateContent because it’s super cheap to maintain that compatibility moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants