# How to validate a front matter in markdown file

**URL:** <https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388>\
**Category:** Help\
**Created:** [January 23, 2018, 9:34am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388 "2018-01-23T09:34:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_raj\_Sundar](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@Deepak\_raj\_Sundar](https://talk.jekyllrb.com/u/Deepak_raj_Sundar)\
**Post date:** [January 23, 2018, 9:34am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388/1 "2018-01-23T09:34:51Z")

</div>

I have a set of markdown files that use YAML syntax for front matter . on passing these files to my jekyll project to build site , i have a set of html files generated . But if any of these files have improper front matter , they remain as .md files and not converted to html .

Now i need to validate the files for front matter before moving them into jekyll project . how can i achieve this ? is there any API or method to validate the file programmatically ?

---

<div class="post-metadata">

**Author:** ![pabloduo](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pabloduo](https://talk.jekyllrb.com/u/pabloduo)\
**Post date:** [January 24, 2018, 7:30am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388/2 "2018-01-24T07:30:58Z")

</div>

Hi there,

First of all Jekyll should fail while executing `build` or `serve` commands if any of your pages has invalid front matter (since it must be a valid YAML snippet).

However, if that doesn’t work (for whatever reason), you can try run jekyll with `--strict_front_matter` switch to request additional scrutiny while generating your pages.

Here is an example how you run jekyll with the switch from command-line:

```auto
bundle exec jekyll build --strict_front_matter
or
bundle exec jekyll serve --strict_front_matter

```

Also, there is an option to enable strict mode by default in your `_config.yml`, here:

```auto
title: "My awesome blog"
url: "https://blog.about.me"
...
# enable strict front matter by default
strict_front_matter: true
...

```

Here you can find reference of additional switches/configuration flags available in Jekyll: [https://jekyllrb.com/docs/configuration/#build-command-options](https://jekyllrb.com/docs/configuration/#build-command-options).

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Deepak\_raj\_Sundar](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@Deepak\_raj\_Sundar](https://talk.jekyllrb.com/u/Deepak_raj_Sundar)\
**Post date:** [January 24, 2018, 8:20am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388/3 "2018-01-24T08:20:04Z")

</div>

HI thanks for your reply , but what i need a validator program , which should check each file for front matter before i pass them to the jekyll project .

as my site gets its md files from different sources , i need to validate them for front matter before using them in my project . hope you understand my requirement now .

---

<div class="post-metadata">

**Author:** ![Frank](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/frank/32/26_2.png) [@Frank](https://talk.jekyllrb.com/u/Frank)\
**Post date:** [January 24, 2018, 10:48am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388/4 "2018-01-24T10:48:57Z")

</div>

You can always check your files with tools like remark:

> **[remark-frontmatter](https://www.npmjs.com/package/remark-frontmatter)**
>
> remark plugin to support frontmatter (yaml, toml, and more)

---

<div class="post-metadata">

**Author:** ![Deepak\_raj\_Sundar](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@Deepak\_raj\_Sundar](https://talk.jekyllrb.com/u/Deepak_raj_Sundar)\
**Post date:** [January 24, 2018, 11:08am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388/5 "2018-01-24T11:08:56Z")

</div>

is there any such plugin in c# ?

---

<div class="post-metadata">

**Author:** ![pabloduo](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@pabloduo](https://talk.jekyllrb.com/u/pabloduo)\
**Post date:** [January 25, 2018, 5:45am UTC](https://talk.jekyllrb.com/t/how-to-validate-a-front-matter-in-markdown-file/1388/6 "2018-01-25T05:45:23Z")

</div>

Sorry, I can’t help but to ask why you aren’t happy with using `jekyll` as your validator? It will be the only answer you can trust at the end of the day - other components may diverge from Jekyll’s definition of `valid front matter` and that fact might (or might not) lead to obscure issues.

Anyhow, in C# you can resort to use projects like YamlDotNet, SharpYaml or ParseYaml (for hands-on experience). Also, here is the list of projects on Github you can consider as well: [https://github.com/topics/yaml?l=c%23](https://github.com/topics/yaml?l=c%23).

Hope it helps.

> **[aaubry/YamlDotNet](https://github.com/aaubry/YamlDotNet)**
>
> YamlDotNet is a .NET library for YAML. Contribute to aaubry/YamlDotNet development by creating an account on GitHub.

> **[xoofx/SharpYaml](https://github.com/xoofx/SharpYaml)**
>
> SharpYaml is a .NET library for YAML compatible with CoreCLR - xoofx/SharpYaml

> **[hkraal/ParseYaml](https://github.com/hkraal/ParseYaml)**
>
> Contribute to hkraal/ParseYaml development by creating an account on GitHub.
