Skip to content

Front matter config#14

Merged
ryanmphill merged 2 commits intomainfrom
front-matter-config
May 25, 2025
Merged

Front matter config#14
ryanmphill merged 2 commits intomainfrom
front-matter-config

Conversation

@ryanmphill
Copy link
Copy Markdown
Owner

@ryanmphill ryanmphill commented May 25, 2025

Front Matter Configuration

Closes #13

This PR adds support for customizing specific metadata for each page using the @frontmatter and @endfrontmatter tags at the beginning of a Jinja template or markdown file, with a json object inside of the tags. The current supported variables are:

lang: The language metadata for the page <head>
title: The title metadata for the page <head>
charset: The charset metadata for the page <head>
description: The description metadata for the page <head>
keywords: Keyword metadata for the page <head>
author: Author metadata for the page <head>
og_image: Open graph image metadata for the page <head>
og_image_alt: Open graph image alt metadata for the page <head>
og_title: Open graph title metadata for the page <head>
og_description: Open graph description metadata for the page <head>
og_url: Open graph URL metadata for the page <head>
og_type: Open graph type metadata for the page <head>
og_site_name: Open graph site name metadata for the page <head>
og_locale: Open graph locale metadata for the page <head>
canonical: Canonical URL metadata for the page <head>
google_font_link: URL link to import google font. Automatically creates the preconnect link tags
preconnects: Any urls that should be preconnected to in the <head> for the page. Generates the <link> tags
stylesheets: Any external stylesheets that should be included on the page
robots: Robots metadata for the page <head>
head_extra: Custom raw string that will be included in the <head>. Should be a valid tag, such as <script> or <link>
body_id: The id attribute for the <body> tag
body_class: The class attribute for the <body> tag

Additionally, these variables can be used on markdown files:
summary: Short version of content
category: Taxonomy to categorize the article (one)
tags: Additional taxonomy for the article (many)
date: Publish date as UTC timestamp
draft: Boolean indicating whether article is a draft. Defaults to "false" if not included
modified: Option to add a UTC timestamp when an article has been edited

Example:

@frontmatter
{
    "title": "Shodo - A Static Site Generator - Home",
    "description": "Home page of the site",
    "keywords": ["home", "site", "example"],
    "author": "Your Name",
    "head_extra": [
        "<link rel='stylesheet' href='/static/css/custom.css'>",
        "<script src='/static/js/custom.js'></script>"
    ]
}
@endfrontmatter

@ryanmphill ryanmphill merged commit c4e86d8 into main May 25, 2025
3 checks passed
@ryanmphill ryanmphill deleted the front-matter-config branch May 25, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The <head> content should be customizable for each page

1 participant