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

Included more details about adding defaults to static files #5971

Merged
merged 2 commits into from Mar 21, 2017
Merged

Included more details about adding defaults to static files #5971

merged 2 commits into from Mar 21, 2017

Conversation

tomjoht
Copy link
Contributor

@tomjoht tomjoht commented Mar 21, 2017

Based on the functionality released in 3.4.2 re adding defaults to static files, I thought this page needed some more detail.

Based on the functionality released in [3.4.2](http://jekyllrb.com/news/2017/03/09/jekyll-3-4-2-released/) re adding defaults to static files, I thought this page needed some more detail.
@tomjoht
Copy link
Contributor Author

tomjoht commented Mar 21, 2017

@jekyll/documentation
@pathawks

@jekyllbot jekyllbot self-assigned this Mar 21, 2017
@DirtyF DirtyF self-assigned this Mar 21, 2017
Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!!


## Add front matter to static files

Although you can't directly add front matter values to static files, you can actually set front matter values through the [defaults property](../configuration/#front-matter-defaults) in your configuration file. When Jekyll builds the site, it will use the front matter values you set.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually

{% if myfile.image == true %}
{{ myfile.path }}
{% endif %}
{% endfor %}{% endraw %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using the where filter here instead of the if in the for loop? It's usually much more performant

{% assign image_files = site.static_files | where: "image", true %}
{% for myimage in image_files %}
  {{ myimage.path }}
{% endfor %}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, let's use the where filter. i'll make the update.

- removed "actually"
- switched code example to use `where`
@DirtyF
Copy link
Member

DirtyF commented Mar 21, 2017

Thanks for this useful addition @tomjohnson1492

@jekyllbot: merge +docs

@jekyllbot jekyllbot merged commit 2c4eebc into jekyll:master Mar 21, 2017
jekyllbot added a commit that referenced this pull request Mar 21, 2017
@jekyll jekyll locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants