DEV Community

Caleb Hearth
Caleb Hearth

Posted on • Originally published at calebhearth.com on

Tell GitHub to Render Markdown Pages with .gitattributes

Articles on Hearthside are written in Markdown (GitHub-flavored), but the file extension is .md.yaml as they also make use of Jekyll-style front matter. My Frontmatter gem requires that files it handles end in .yaml or .yml, so this is necessary.

Because of the file extension, GitHub until this week did not render the Markdown correctly. Instead articles have been highlighted if they were written in YAML completely, which really messes up the Syntax highlighting even beyond not giving a rendered preview.

I’m not sure why I never thought to look into it in the last several years of writing this way, but it turns out that you can tell GitHub’s Linguist tool what type of language a file type should match, so to do that I added this to my project’s .gitattributes:

*.md.y*ml linguist-language=markdown 
Enter fullscreen mode Exit fullscreen mode

Read More

Top comments (1)

Collapse
 
sloan profile image
Sloan the DEV Moderator

Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link.

Sharing your full posts helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section on DEV.

To be clear, the DEV Terms state:

Posts must contain substantial content — they may not merely reference an external link that contains the full post.

Also, if you share your full post, you have the option to add a canonical URL directly to your post. This helps with SEO if you are reposting articles!