PHPackages                             tinydots/craft-front-matter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. tinydots/craft-front-matter

ActiveCraft-plugin[Parsing &amp; Serialization](/categories/parsing)

tinydots/craft-front-matter
===========================

Extract YAML data from twig templates

1.1.0(7y ago)023MITPHP

Since Dec 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/tinydots/craft-front-matter)[ Packagist](https://packagist.org/packages/tinydots/craft-front-matter)[ RSS](/packages/tinydots-craft-front-matter/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

Front Matter for Craft CMS 3.x
==============================

[](#front-matter-for-craft-cms-3x)

[![Build Status](https://camo.githubusercontent.com/4a305d3926c232f5e34a78be1353b008a60902c9eb9d3bbabb9fa1fea249e55d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74696e79646f74732f63726166742d66726f6e742d6d61747465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/tinydots/craft-front-matter/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/da308e5dbe60cc3f69a86b74f46d6e419eff131c345fd55c3b149d9846288aab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74696e79646f74732f63726166742d66726f6e742d6d61747465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/tinydots/craft-front-matter/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/22be6f8af8363372e237b92ea3cf833c8c0ae64a3ac1c7bc75f83bec46e15a6d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74696e79646f74732f63726166742d66726f6e742d6d61747465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/tinydots/craft-front-matter/?branch=master)[![License](https://camo.githubusercontent.com/8218f63ad4caafda1824e778e8bac37cf8b197dcc866134ade0e5b11b2f22329/68747470733a2f2f706f7365722e707567782e6f72672f74696e79646f74732f63726166742d66726f6e742d6d61747465722f6c6963656e7365)](https://packagist.org/packages/tinydots/craft-front-matter)

Front Matter allows you to extract [YAML](http://yaml.org/spec/1.2/spec.html) data from specially-formatted comments at the top of your twig templates. This is especially useful for including a pattern library inside your Craft CMS project.

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 3.0.0 or later.

Installation
------------

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

    `cd /path/to/project`
2. Then tell Composer to load the plugin:

    `composer require tinydots/craft-front-matter`
3. In the Control Panel, go to Settings -&gt; Plugins and click the “Install” button for Front Matter.

Usage
-----

[](#usage)

### Defining data

[](#defining-data)

You can add YAML metadata to the top of any twig template by surrounding it in `{#---` and `---#}` tags. Because the YAML data is inside a twig comment, you can still `{% include %}` and `{% embed %}` templates as normal, with or without the plugin installed.

Given a `_components/link.html` template for rendering a link, with the following YAML front matter data:

```
{#---
title: Link
description: >
    This is a tiny component for rendering a single link.

        {% include "_components/link" with {
            url: 'https://www.google.com',
            text: 'Google',
        } %}
variables:
    text: The text to use as the body of the link
    url: The url of the target
examples:
    - text: Craft CMS
      url: https://www.craftcms.com
    - text: Google
      url: https://www.google.com
---#}

{{ text }}
```

### Accessing data

[](#accessing-data)

You can access the YAML data as an array from other templates with `craft.frontMatter.parse(template)`:

```
{% set component = craft.frontMatter.parse("_components/link") %}

{{ component.title }}

{{ component.description|markdown }}
```

### Pattern Libraries

[](#pattern-libraries)

The main use-case for embedding YAML data in templates is for creating a style guide or pattern library inside the Craft project itself.

Collections/arrays are available to use as normal so can be used to document the variables the template accepts:

```
{% if component.variables is defined %}
    Variables

        {% for variable, description in component.variables %}
            {{ variable }}
            {{ description|markdown }}
        {% endfor %}

{% endif %}
```

You can output the escaped source of the template *without* the YAML data, using `craft.frontMatter.source(template)`:

```
Source code

    {{- craft.frontMatter.source("_components/link") -}}

```

If you use simple strings and arrays as input variables in your template, you can even embed a few examples of the output by passing them back in to a normal `{% include %}` of the template:

```
{% if component.examples is defined %}
    Examples

    {% for example in component.examples %}

        {# Output the rendered template with the example data #}
        {% include "_components/link" with example only %}

        {# Output the escaped rendered HTML output#}
        {% filter escape('html') %}{% include "_components/link" with example only %}{% endfilter %}

    {% endfor %}
{% endif %}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

2

Last Release

2707d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b5c88d20d8c13b68ccbe87db6ac2e7228d39ee47732fc851bd8d954b4d51bde7?d=identicon)[tinydots](/maintainers/tinydots)

---

Top Contributors

[![mdcpepper](https://avatars.githubusercontent.com/u/89459?v=4)](https://github.com/mdcpepper "mdcpepper (23 commits)")

---

Tags

yamlcmsCraftcraftcmscraft-pluginfront matter

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/tinydots-craft-front-matter/health.svg)

```
[![Health](https://phpackages.com/badges/tinydots-craft-front-matter/health.svg)](https://phpackages.com/packages/tinydots-craft-front-matter)
```

###  Alternatives

[nystudio107/craft-seomatic

SEOmatic facilitates modern SEO best practices &amp; implementation for Craft CMS 5. It is a turnkey SEO system that is comprehensive, powerful, and flexible.

1741.4M46](/packages/nystudio107-craft-seomatic)[verbb/image-resizer

Resize assets when they are uploaded.

127269.1k7](/packages/verbb-image-resizer)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[verbb/hyper

A user-friendly links field for Craft.

24130.9k9](/packages/verbb-hyper)[verbb/social-poster

Automatically post entries to social media.

918.5k](/packages/verbb-social-poster)[hut6/oembed

A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.

102.3k](/packages/hut6-oembed)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
