Markdown metadata format

后端 未结 7 1229
独厮守ぢ
独厮守ぢ 2020-12-29 18:44

Is there a standard or convention for embedding metadata in a Markdown formatted post, such as the publication date or post author for conditional rendering by the renderer?

相关标签:
7条回答
  • 2020-12-29 19:27

    Correct.

    Use the yaml front matter key-value syntax — like MultiMarkdown supports — but (ab)use the official markdown URL syntax to add your metadata.

    … my workaround looks like this:

    ---
    [//]: # (Title: My Awesome Title)
    [//]: # (Author: Alan Smithee)
    [//]: # (Date: 2018-04-27)
    [//]: # (Comment: This is my awesome comment. Oh yah.) 
    [//]: # (Tags: #foo, #bar)  
    [//]: # (CSS: https://path-to-css)  
    ---
    

    Put this block at the top of your .md doc, with no blank line between the top of the doc and the first ---.

    Your fake yaml won't be included when you render to HTML, etc. … it only appears in the .md.

    You can also use this technique for adding comments in the body of a markdown doc.

    0 讨论(0)
提交回复
热议问题