admin管理员组

文章数量:1292175

I want to take some posts of a similar type, split them into named building blocks, store those separately, and finally put them together in a consistent nature using templates while rendering.

For example, I want my technical posts to resemble the structure of how I normally ask questions on the StackExchange sites, for example:

  • What is the problem?
  • What was my research?
  • The solution I found
  • Sources and further reading

Normally I would write out a post into a single uniform body, and just split it with h1's. Problem is, if I later decided to

  • replace h1's with h2's, or
  • make each of those headers have a permalinkable #anchor, or
  • make the research block collapsed by default because most Googlers want just the answer anyway, or
  • mark them up as structured data, or in any other way I am not yet aware of,

I would have to edit all posts – which would be a lot of ineffective, error prone manual work. Instead, I would prefer to simply edit one reusable template.

I am therefore looking for a way to separate content from the templates, while enforcing a rigid post structure. This resembles how the interfaces are being used in programming: if a given class implements some interface, this is a guarantee that it will have all methods defined in that interface, otherwise the compiler throws an error and won't let the program continue. Or in my case, if a post implements the e.g. "Q&A" type, this should be a guarantee it has all of the above sections.

Here's what I found:

  • Custom fields won't work because apparently they're plain text
  • Post formats won't work either because they do not enforce any post structure and are merely an indicator for the theme on how to render the post

本文标签: Enforcing a rigid reusable template structure for similar posts