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

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

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

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

yimingtang opened this issue Jun 16, 2014 · 9 comments

Comments

@yimingtang
Copy link

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
Copy link
Member

parkr commented Jun 17, 2014

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

@yimingtang
Copy link
Author

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
Copy link
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
Copy link

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
Copy link
Author

@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
Copy link
Author

@omegahm Yes. The behavior is really strange.

@budparr
Copy link

budparr commented Jun 17, 2014

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

@parkr
Copy link
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
Copy link
Member

parkr commented Jul 31, 2014

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

@parkr parkr closed this as completed 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.
Projects
None yet
Development

No branches or pull requests

5 participants