Remove YAML Front Matter
There are many ways to remove YAML Front Matter, here is how I use sed
to do so:
1 | sed -i '1 { /^---/ { :a N; /\n---/! ba; d} }' INPUT_FILE |
Explanation:
1 | 1 { # in the first line |
Furthermore, if you wanna keep some useful metadata in front matter like post title in blogging system, you can do so:
1 | title=$(grep '^title\:\(.*\)$' $1 | sed -e 's/title\:\s//g') |
Here is a workaround to insert $title
in each ---
then remove YAML Front Matter.
References: