Skip to content

Instantly share code, notes, and snippets.

@peterc
Last active March 2, 2019 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterc/4b0600ce36f118240bdee2b02b6219b2 to your computer and use it in GitHub Desktop.
Save peterc/4b0600ce36f118240bdee2b02b6219b2 to your computer and use it in GitHub Desktop.
Can HTML work as a format for sub-documents?

Let's say I want to create and share a document, such as a blog post that has various components:

  • meta information (author, categories, tags..)
  • a title
  • body content
  • some custom styling
  • some custom scripting

An HTML document seems like a great way to portably and easily package all of these things into one place:

<html>
<head>
  <title>My blog post</title>
  <meta name="author" content="My Name Here">
  <meta name="description" content="Something describing my blog post">
  <link rel="stylesheet" href="custom-styles-for-this-blog-post.css">
</head>
<body>
  <p>Hello world, this is my amazing blog post!</p>
  <script>
    // some custom scripting here, maybe for an interactive demo
  </script>
</body>
</html>

This seems efficient and portable, but it looks too much like a very bare standalone HTML document rather than something designed to integrate within a broader template or system (CMS, static site generator, etc.)

Are there any established approaches to distinguish this sort of child/sub-document (that's designed to be integrated with a CMS or static site generator of some sort) from a truly standalone HTML document?

Also, are there any established standards for integrating such content into broader HTML templates? I would expect the CSS and JavaScript within the "blog post" to become scoped to just the content in that blog post, for instance.

Further points:

  • Embedding (such as with an iframe does not count, I feel, as this works poorly in most browsers, IMHO.
  • I want such a document to stand alone and be easily shared to be used by many blogs or CMSes, so I don't want to include calls to templating from the document itself (e.g. PHP includes). The document needs to stand separate from whatever templating it gets integrated with eventually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment