Skip to content

Bug? Empty variables are removed from frontmatter #327

@kevinpapst

Description

@kevinpapst

I promise this is one of the last 5 issues I open 😁

You have that code in place inside convert_posts which removes certain frontmatter variables.
I am using Jekyll since years now and Liquid has kinda autoboxes certain values like PHP, but I am using a lot of bool and empty string values in my current wordpress theme to check for conditions.

foreach ( $meta as $key => $value ) {
if ( ! is_numeric( $value ) && ! $value ) {
unset( $meta[ $key ] );
}
}

When I do the export, half of the variables are missing in my frontmatter in certain files. This makes it more complicated for me to write the correct code, because I cannot assume that the fields are always there.
Maybe its just my dev brain that tries toi make it failsafe, but also larger search&replace actions are more complicated, because the keys are available in some files and not others.

I simply commented the unset line, but I wanted to point out that this behavior is (for me) unexpected. An exporter should export and not make decisions of what is a key of value and which ones are "use-less". Can I ask for the why of that code?

I can raise a PR to remove this foreach, but I guess this one is again a matter of opinion and I can also include it in a PR where I am going to add some docs for the next person.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions