How to get the un-rendered content of a post? #2522

Closed
yimingtang opened this Issue Jun 16, 2014 · 9 comments

Comments

Projects
None yet
5 participants
@yimingtang

Hi, I'm using Jekyll 2.0.3.

I want to get the un-rendered excerpt or content of a post. After a little investigation, I found that the values of content and excerpt are rendered HTML content. However, this reference says they are un-rendered content.

I'm so confused. Is it outdated?

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Jun 17, 2014

Member

content should contain your unrendered content. Are you seeing the rendered content there?

Member

parkr commented Jun 17, 2014

content should contain your unrendered content. Are you seeing the rendered content there?

@yimingtang

This comment has been minimized.

Show comment
Hide comment
@yimingtang

yimingtang Jun 17, 2014

Yes, the rendered content. I use markdown files as my posts. Here is my code snippet.

{% for post in paginator.posts %}
  <article class="post">
    <header>{{ post.title }}</header>
    <section class="post-content">
      {{ post.content }}
    </section>
  </article>
{% endfor %}

The result of post.content is rendered content. Am I doing it wrong?

Yes, the rendered content. I use markdown files as my posts. Here is my code snippet.

{% for post in paginator.posts %}
  <article class="post">
    <header>{{ post.title }}</header>
    <section class="post-content">
      {{ post.content }}
    </section>
  </article>
{% endfor %}

The result of post.content is rendered content. Am I doing it wrong?

@omegahm

This comment has been minimized.

Show comment
Hide comment
@omegahm

omegahm Jun 17, 2014

Contributor

I can confirm that when using either site.posts or paginator.posts the post.content is indeed already rendered, however, when inside the post layout, page.content yields the unrendered version, while content is still rendered.

Jekyll 1.5.1

Contributor

omegahm commented Jun 17, 2014

I can confirm that when using either site.posts or paginator.posts the post.content is indeed already rendered, however, when inside the post layout, page.content yields the unrendered version, while content is still rendered.

Jekyll 1.5.1

@budparr

This comment has been minimized.

Show comment
Hide comment
@budparr

budparr Jun 17, 2014

Contributor

I'm not sure if I'm understanding what you want, but if you want post.content converted from markdown you have to use a filter {{ post.content | markdownify }}

Contributor

budparr commented Jun 17, 2014

I'm not sure if I'm understanding what you want, but if you want post.content converted from markdown you have to use a filter {{ post.content | markdownify }}

@yimingtang

This comment has been minimized.

Show comment
Hide comment
@yimingtang

yimingtang Jun 17, 2014

@budparr Actually, post.content is in HTML format, but it should be markdown format according to the docs. So you don't have to call markdownify.

@budparr Actually, post.content is in HTML format, but it should be markdown format according to the docs. So you don't have to call markdownify.

@yimingtang

This comment has been minimized.

Show comment
Hide comment
@yimingtang

yimingtang Jun 17, 2014

@omegahm Yes. The behavior is really strange.

@omegahm Yes. The behavior is really strange.

@budparr

This comment has been minimized.

Show comment
Hide comment
@budparr

budparr Jun 17, 2014

Contributor

Ah, I see. You said you were using md files, not html files.

Contributor

budparr commented Jun 17, 2014

Ah, I see. You said you were using md files, not html files.

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Jul 31, 2014

Member
  • content ought to be the rendered content (no layout)
  • output ought to be the rendered content (with the layout(s))
Member

parkr commented Jul 31, 2014

  • content ought to be the rendered content (no layout)
  • output ought to be the rendered content (with the layout(s))
@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Jul 31, 2014

Member

But it works differently for pages vs. posts vs. documents. This is thorny.

Member

parkr commented Jul 31, 2014

But it works differently for pages vs. posts vs. documents. This is thorny.

@parkr parkr closed this in d050fd1 Jul 31, 2014

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.