Snippets - novoid/lazyblorg GitHub Wiki
Snippets are reusable content fragments that can be defined once and referenced from any blog article. When the blog is generated, snippet references are replaced with the snippet’s content.
A snippet is a regular Org-mode entry with the tag lbsnippet (in
addition to the required blog tag). Like any blog entry, it needs:
-
:blog:lbsnippet:tags - A unique
:ID:property -
DONEstate -
:LOGBOOK:drawer with DONE state transition timestamp -
:CREATED:property
Example:
** DONE My reusable disclaimer :blog:lbsnippet:
CLOSED: [2026-01-01 Wed 10:00]
:LOGBOOK:
- State "DONE" from "" [2026-01-01 Wed 10:00]
:END:
:PROPERTIES:
:CREATED: [2026-01-01 Wed 09:00]
:ID: my-disclaimer
:END:
This article represents my personal opinion and not that of my employer.
Snippet entries are not published as blog articles. They exist only to provide content for other entries.
Use standard Org-mode ID links to reference a snippet:
-
[[id:my-disclaimer]]— bracket link syntax -
id:my-disclaimer— bare ID reference
Both forms work identically.
Note: Described links like [[id:my-disclaimer][some text]] will
trigger a warning. The description text is ignored and the snippet
content is substituted instead.
When a snippet reference is the only content of a paragraph, the entire paragraph is replaced with all of the snippet’s content elements (paragraphs, headings, lists, etc.).
Example:
Some intro text.
[[id:my-disclaimer]]
More text after.
When a snippet reference appears within other text, only the text content of the snippet’s paragraphs is substituted inline.
Example:
Please note: [[id:my-disclaimer]] Thank you.
If an inline-referenced snippet contains non-paragraph elements (headings, lists, etc.), a warning is logged and only the paragraph text is used.
When a snippet containing headings is inserted via block replacement, the heading levels are automatically adapted to match the context. The headings are shifted so they appear as sub-headings of the previous heading at the insertion point.
For example, if the insertion point follows a level-3 heading and the snippet’s first heading is level 2, all snippet headings are shifted up by 2 levels (level 2 becomes level 4, level 3 becomes level 5, etc.).
Snippets can reference other snippets. The inner snippets are resolved first, then the outer ones. This allows you to compose complex reusable content from smaller building blocks.
Circular references (snippet A references snippet B which references snippet A) are detected and cause an error with a clear message showing the full reference chain.
Self-referencing snippets are also detected.