I decided I wanted a little help making filenames and front matter. This post’s filename and front matter was created with this script I just whipped up. I copy/pasted the result.

Update: I decided to add an “updated” field to the front matter, so I updated this post with the info. And I threw it up on Gist, too.

<#
.Synopsis
   Generates file name and front matter scaffolding for a Jekyll post.
.DESCRIPTION
   Given a post title string, creates file name and front matter for a Jekyll
   post using the current date and time. Optionally creates the file in the
   .\_posts directory or designated -Path\_posts or -PostsPath.
.EXAMPLE
   New-JekyllPost "Title of the new post"
.EXAMPLE
   New-JekyllPost "Title of the new post" -CreateFile -Path \path\to\jekyll
#>
function New-JekyllPost {
    param(
        [string]$Title = "This is a title",
        [string]$Path = ".",
        [string]$PostsPath = "$Path/_posts",
        [datetime]$Date = (Get-Date),
        [string]$SubPath = ($Date.Year),
        [switch]$CreateFile
    )
    $FileName = "{0}-{1}.md" -f (Get-Date ($Date) -Format "yyyy-MM-dd"), ($Title.ToLower() -replace '\W+', '-' -replace '-+$')
    $Content = @(
        "---"
        "layout: post"
        "title:  $Title"
        "date:   {0}" -f (Get-Date ($Date) -Format "yyyy-MM-dd HH:mm:ss zzz") -replace ':00$', '00'
        "---"
    ) -join "`n"
    if ($CreateFile) {
        $File = New-Item -ItemType File -Path ("{0}/{1}/{2}" -f $PostsPath, $SubPath, $FileName)
        Set-Content -Path $File -Value $Content
        Write-Output $File
    } else {
        Write-Output $FileName
        Write-Output $Content
    }
}

<#
.Synopsis
   Generates last_modified_at front matter for a Jekyll post.
.DESCRIPTION
   Generates last_modified_at front matter for a Jekyll post based on the current
   date and time. To be copied and pasted into the front matter.
.EXAMPLE
   Update-JekyllPost
.EXAMPLE
   Update-JekyllPost | Set-Clipboard
#>
function Update-JekyllPost {
    param(
        [datetime]$Date = (Get-Date)
    )
    "last_modified_at: {0}" -f (Get-Date ($Date) -Format "yyyy-MM-dd HH:mm:ss zzz") -replace ':00$', '00'
}

Command:

New-JekyllPost "Powershell date and front matter for Jekyll"

Copy-and-paste-able output:

2016-12-13-powershell-date-and-front-matter-for-jekyll.md
---
layout: post
title:  Powershell date and front matter for Jekyll
date:   2016-12-13 04:26:32 -0600
---

Update command:

Update-JekyllPost

Output:

last_modified_at: 2016-12-13 13:25:53 -0600