diff options
-rw-r--r-- | content/posts/hugo-org-archetype/index.org | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/content/posts/hugo-org-archetype/index.org b/content/posts/hugo-org-archetype/index.org new file mode 100644 index 0000000..b0f1f34 --- /dev/null +++ b/content/posts/hugo-org-archetype/index.org @@ -0,0 +1,57 @@ +#+TITLE: Hugo Org Archetype +#+DATE: 2020-06-24T17:42:11-04:00 +#+DRAFT: true +#+DESCRIPTION: +#+TAGS[]: hugo org-mode +#+KEYWORDS[]: hugo org-mode +#+SLUG: +#+SUMMARY: + +I love using [[https://gohugo.io/content-management/archetypes/][Hugo]] to write. Their [[https://orgmode.org/][org-mode]] markup support is +absolutely top notch. The only real problem with it is that while it's +well supported, the Hugo docs don't cover it very much, as [[https://daringfireball.net/projects/markdown/][Markdown]] +and [[https://toml.io/en/][TOML]] are the main markup and configuration languages. + +One of the basic building blocks for Hugo blogs are +[[https://gohugo.io/content-management/archetypes/][Archetypes]]. Archetypes get used as the templates for new posts, and +get automatically filled out with the title of the post and creation +date. + +Instead of writing the front matter of my posts in TOML, I use +org-mode syntax, to keep the entire document uniformly org-ish. + +To setup an org-mode archetype, create the file =[site +root]/archetypes/default.org= with the following contents: + +#+BEGIN_SRC org +#+TITLE: {{ replace .Name "-" " " | title }} +#+DATE: {{ .Date }} +#+DRAFT: true +#+DESCRIPTION: +#+TAGS[]: +#+KEYWORDS[]: +#+SLUG: +#+SUMMARY: +#+END_SRC + +While this template doesn't contain every predefined front matter +variable, it contains all of the ones I use regularly. You can find a +full list of predefined variables [[https://gohugo.io/content-management/front-matter/][here]]. The theme I use actually +doesn't use the =#+KEYWORDS[]:= variable as it just uses the tags as +keywords, but I fill it out the same as the =#+TAGS[]:= variable in +case I ever change themes. It doesn't hurt to have more variables in +the template than you use, as empty variables are not used in the +output. + +The theme you use may also have its own custom front matter +variables. + +Now when I create a post, if the name of the post ends in =.org=, the +=default.org= archetype file is used. For example to create this post, +I ran + +#+BEGIN_SRC shell +hugo new posts/hugo-org-archetype.org +#+END_SRC + +Then I open it in Emacs, and start typing! |