Commit 669d193f authored by Kaushal Modi's avatar Kaushal Modi
parent 3e519f77
#+DATE: July 6, 2017
* How to compile the site
1. Be the root directory for this Hugo site (the directory containing =config.toml=).
2. Run "hugo server --port 1111"
3. See the site served on "http://localhost:1111/"
* Source blog posts in Org
Location: =<HUGO_BASE_DIR>/content-org/=
The directory does not have to be =content-org=, but it has to be
outside the =hugo= Contents dir =content/=.
* Tested to work on
- hugo v0.25-DEV updated today
- org master updated today
- emacs master updated today
+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = {{ .Date }}
draft = true
+++
baseURL = "http://example.org/"
languageCode = "en-us"
title = "Hugo Scratch Pad"
theme = "bare_min"
canonifyURLs = true
enableEmoji = true
# enableGitInfo = true
disableFastRender = true # Hugo 0.30
pygmentsCodeFences = true # This applies to Chroma too.
pygmentsUseClasses = true # This applies to Chroma too.
[[menu.main]]
name = "labs"
weight = -110
identifier = "labs"
url = "/labs/"
This diff is collapsed.
#+HUGO_BASE_DIR: ../
#+SEQ_TODO: TODO DRAFT DONE
# Auto-set lastmod field in the below posts.
#+HUGO_AUTO_SET_LASTMOD: t
* Auto-set Lastmod
:PROPERTIES:
:EXPORT_FILE_NAME: auto-set-lastmod
:END:
This post will have its =lastmod= field in the front-matter
auto-updated the time it gets exported each time.
#+HUGO_BASE_DIR: ../
#+HUGO_FRONT_MATTER_FORMAT: yaml
#+HUGO_MENU: :menu main :parent posts
* Menu Meta Data in YAML Front Matter :menu:yaml:
:PROPERTIES:
:EXPORT_FILE_NAME: menu-meta-data-yaml
:EXPORT_DATE: 2017-07-18
:EXPORT_HUGO_MENU_OVERRIDE: :weight 25 :identifier yaml-menu-override
:END:
Testing the addition of /menu/ meta data to the YAML front
matter. Here the front matter format is set to YAML using the
=#+HUGO_FRONT_MATTER_FORMAT= keyword.
Later only the /weight/ and /identifier/ menu properties are
overridden using =EXPORT_HUGO_MENU_OVERRIDE= key in the property drawer.
#+HUGO_BASE_DIR: ../
* Introduction
See https://github.com/kaushalmodi/ox-hugo/issues/81
#+BEGIN_QUOTE
I'd like to be able to write a book for the [[http://docdock.netlify.com/content-organisation/][docdock theme]]. It says to
nest content like this:
#+BEGIN_EXAMPLE
content
├── level-one
│ ├── level-two
│ │ ├── level-three
│ │ │ ├── level-four
│ │ │ │ ├── _index.md
│ │ │ │ ├── page-4-a.md
│ │ │ │ ├── page-4-b.md
│ │ │ │ └── page-4-c.md
#+END_EXAMPLE
#+END_QUOTE
* Books
** book1
:PROPERTIES:
:EXPORT_HUGO_SECTION: book1
:END:
*** Index
:PROPERTIES:
:EXPORT_FILE_NAME: _index
:END:
Book 1 index.
This type of organization will generate this in the =content/=
directory:
#+BEGIN_EXAMPLE
> tree book1
book1
├── chapter1
│   ├── _index.md
│   ├── section1.md
│   └── section2.md
├── chapter2
│   ├── _index.md
│   ├── section1.md
│   └── section2.md
└── _index.md
#+END_EXAMPLE
- [[/book1/chapter1][Chapter 1]]
- [[/book1/chapter1/section1][Chapter 1 Section 1]]
- [[/book1/chapter1/section2][Chapter 1 Section 2]]
- [[/book1/chapter2][Chapter 2]]
- [[/book1/chapter2/section1][Chapter 2 Section 1]]
- [[/book1/chapter2/section2][Chapter 2 Section 2]]
*** chapter 1
:PROPERTIES:
:EXPORT_HUGO_SECTION: book1/chapter1
:END:
**** Chapter 1 Index
:PROPERTIES:
:EXPORT_FILE_NAME: _index
:END:
Introduction for chapter 1
**** sub section 1
:PROPERTIES:
:EXPORT_FILE_NAME: section1
:END:
Section 1 of chapter 1
**** sub section 2
:PROPERTIES:
:EXPORT_FILE_NAME: section2
:END:
Section 2 of chapter 1
*** chapter 2
:PROPERTIES:
:EXPORT_HUGO_SECTION: book1/chapter2
:END:
**** Chapter 2 Index
:PROPERTIES:
:EXPORT_FILE_NAME: _index
:END:
Introduction for chapter 2
**** sub section 1
:PROPERTIES:
:EXPORT_FILE_NAME: section1
:END:
Section 1 of chapter 2
**** sub section 2
:PROPERTIES:
:EXPORT_FILE_NAME: section2
:END:
Section 2 of chapter 2
#+HUGO_BASE_DIR: ../
#+SEQ_TODO: TODO DRAFT DONE
#+HUGO_MENU: :menu "auto weight"
* Post with menu 1 (HUGO_MENU as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: hugo-menu-as-keyword--post-with-menu-1
:END:
* Post with menu 2 (HUGO_MENU as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: hugo-menu-as-keyword--post-with-menu-2
:END:
* Post with menu 3 (HUGO_MENU as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: hugo-menu-as-keyword--post-with-menu-3
:END:
* Post with menu 4 (HUGO_MENU as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: hugo-menu-as-keyword--post-with-menu-4
:END:
* Post with menu 5 (HUGO_MENU as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: hugo-menu-as-keyword--post-with-menu-5
:END:
#+HUGO_BASE_DIR: ../
#+SEQ_TODO: TODO DRAFT DONE
#+HUGO_WEIGHT: auto
#+HUGO_TAGS: weight
* Post 1 with auto calculation of weight (HUGO_WEIGHT as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: post-1-with-auto-calc-of-weight--hugo-weight-as-keyword
:END:
* Post 2 with auto calculation of weight (HUGO_WEIGHT as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: post-2-with-auto-calc-of-weight--hugo-weight-as-keyword
:END:
* Post 3 with auto calculation of weight (HUGO_WEIGHT as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: post-3-with-auto-calc-of-weight--hugo-weight-as-keyword
:END:
* Post 4 with auto calculation of weight (HUGO_WEIGHT as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: post-4-with-auto-calc-of-weight--hugo-weight-as-keyword
:END:
* Post 5 with auto calculation of weight (HUGO_WEIGHT as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: post-5-with-auto-calc-of-weight--hugo-weight-as-keyword
:END:
#+HUGO_BASE_DIR: ../../
#+HUGO_SECTION: images-in-content
* Post 1
:PROPERTIES:
:EXPORT_FILE_NAME: post1
:END:
Post 1 contents
[[file:gnu.png]]
* Post 2
:PROPERTIES:
:EXPORT_FILE_NAME: post2
:END:
Post 2 contents
[[file:org.png]]
* Proposal
#+BEGIN_EXAMPLE
./content-org ./content
├── post1/ │
│ ├── post1.org -------> ├── post1.md
│ │ ├── post1/
│ └── foo.png -------> │ └── foo.png
└── post2/ │
├── post2.org -------> ├── post2.md
│ └── post2/
├── zoo.pdf -------> ├── zoo.pdf
└── bar.png -------> └── bar.png
#+END_EXAMPLE
* Footnotes
* COMMENT Local Variables :ARCHIVE:
# Local Variables:
# fill-column: 70
# eval: (auto-fill-mode 1)
# eval: (add-hook 'after-save-hook #'org-hugo-export-subtree-to-md-after-save :append :local)
# End:
#+HUGO_BASE_DIR: ../
#+SEQ_TODO: TODO DRAFT DONE
* abc
Running =org-hugo-export-current-subtree= here will throw this user
error:
#+BEGIN_EXAMPLE
user-error: It is mandatory to have a subtree with EXPORT_FILE_NAME property
#+END_EXAMPLE
#+HUGO_BASE_DIR: ../
#+HUGO_SECTION: ./
#+HUGO_WEIGHT: auto
#+HUGO_AUTO_SET_LASTMOD: t
* Emacs :@emacs:
All posts in here will have the category set to /emacs/.
** TODO Writing Hugo blog in Org :hugo:org:
:PROPERTIES:
:EXPORT_FILE_NAME: writing-hugo-blog-in-org-subtree-export
:EXPORT_DATE: 2017-09-10
:EXPORT_HUGO_MENU: :menu "main"
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :foo bar :baz zoo :alpha 1 :beta "two words" :gamma 10
:END:
*** First heading within the post
- This post will be exported as
=content/posts/writing-hugo-blog-in-org-subtree-export.md=.
- Its title will be "Writing Hugo blog in Org".
- It will have /hugo/ and /org/ tags and /emacs/ as category.
- The menu item /weight/ and post /weight/ are auto-calculated.
- The menu item /identifier/ is auto-set.
- The /lastmod/ property in the front-matter is set automatically to
the time of export.
**** A sub-heading under that heading
- It's draft state will be marked as =true= as the subtree has the
todo state set to /TODO/.
With the point _anywhere_ in this /Writing Hugo blog in Org/ post
subtree, do =C-c C-e H H= to export just this post.
The exported Markdown has a little comment footer as set in the /Local
Variables/ section below.
* Footnotes
* COMMENT Local Variables :ARCHIVE:
# Local Variables:
# fill-column: 70
# eval: (auto-fill-mode 1)
# eval: (add-hook 'after-save-hook #'org-hugo-export-subtree-to-md-after-save :append :local)
# org-hugo-footer: "\n\n[//]: # \"Exported with love from a post written in Org mode\"\n[//]: # \"- https://github.com/kaushalmodi/ox-hugo\""
# End:
#+TITLE: Table with Org markup where the markup is ignored
# Ignore the Org emphasis characters like * and /
#+OPTIONS: *:nil
#+HUGO_BASE_DIR: ../../
| QueryID | SQL Text | Query Time (Seconds) | Query Time Hot (Seconds) |
|---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+--------------------------|
| | | | |
| Q0 | SELECT cab_type, count(*) FROM trips_log GROUP BY cab_type; | 10.14 | 11.57 |
| Q1 | SELECT passenger_count, avg(total_amount) FROM trips_log GROUP BY passenger_count; | 12.00 | 6.27 |
| Q2 | SELECT passenger_count, toYear(pickup_datetime) AS year, count(*) FROM trips_log GROUP BY passenger_count, year; | 10.45 | 7.23 |
| Q3 | SELECT passenger_count, toYear(pickup_datetime) AS year, round(trip_distance) AS distance, count(*) FROM trips_log GROUP BY passenger_count, year, distance ORDER BY year, count(*) DESC; | 13.03 | 10.80 |
#+TITLE: Hugo auto weight ineffective for per-file exports
#+HUGO_BASE_DIR: ../../
#+HUGO_WEIGHT: auto
#+HUGO_TAGS: weight
Even though we have =#+HUGO_WEIGHT: auto= in this file, the weight
will be treated as nil as this file is exported using the /per-file/
or /complete-file/ export flow.
The auto-weight calculation works *only* for /per-subtree/ flow.
#+TITLE: Single Post, but draft
#+DATE: 2017-07-20
#+HUGO_PUBLISHDATE: 2017-07-22
#+HUGO_EXPIRYDATE: 2017-07-23
#+HUGO_BASE_DIR: ../../
#+HUGO_SECTION: singles
#+HUGO_TAGS: single toml
#+HUGO_CATEGORIES: cat1 cat2
#+HUGO_MENU: :menu "foo" :weight 10 :parent main
#+HUGO_DRAFT: true
This is a single post. You do not need to set the =EXPORT_FILE_NAME=
property in here. But then you also lose the tag and property
inheritance, TODO state, etc. Org awesomeness.
* First heading in this post
This is a under first heading.
* Second heading in this post
This is a under second heading.
#+TITLE: Single Post with TOML front matter
#+DATE: 2017-07-20
#+HUGO_PUBLISHDATE: 2017-07-22
#+HUGO_EXPIRYDATE: 2017-07-23
#+HUGO_BASE_DIR: ../../
#+HUGO_SECTION: singles
#+HUGO_TAGS: single toml
#+HUGO_CATEGORIES: cat1 cat2
#+HUGO_MENU: :menu "foo" :weight 10 :parent main :identifier single-toml
This is a single post. You do not need to set the =EXPORT_FILE_NAME=
property in here. But then you also lose the tag and property
inheritance Org awesomeness.
* First heading in this post
This is a under first heading.
* Second heading in this post
This is a under second heading.
#+TITLE: Single Post with YAML front matter
#+DATE: 2017-07-20
#+HUGO_PUBLISHDATE: 2017-07-22
#+HUGO_EXPIRYDATE: 2017-07-23
#+HUGO_BASE_DIR: ../../
#+HUGO_FRONT_MATTER_FORMAT: yaml
#+HUGO_SECTION: singles
#+HUGO_TAGS: single yaml
#+HUGO_CATEGORIES: cat1 cat2
#+HUGO_MENU: :menu "foo" :weight 10 :parent main :identifier single-yaml
This is a single post. You do not need to set the =EXPORT_FILE_NAME=
property in here. But then you also lose the tag and property
inheritance, TODO state, etc. Org awesomeness.
* First heading in this post
This is a under first heading.
* Second heading in this post
This is a under second heading.
#+HUGO_BASE_DIR: ../
#+HUGO_CODE_FENCE:
# Below will also do the same thing (because using
# org-hugo--plist-get-true-p instead of just plist-get).
# #+HUGO_CODE_FENCE: nil
#
# Below will use Markdown code fence instead of the highlight
# shortcode.
# #+HUGO_CODE_FENCE: t
#+SEQ_TODO: TODO DRAFT DONE
* Source blocks with Hugo =highlight= shortcode
:PROPERTIES:
:EXPORT_FILE_NAME: shortcode-src-blocks
:EXPORT_DATE: 2017-07-13T17:57:58-04:00
:END:
Here are few variables that you might like to change in the =local.mk=:
- =prefix= :: Org installation directory
#+BEGIN_SRC makefile
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
#+END_SRC
The =.el= files will go to =$(prefix)/emacs/site-lisp/org= by
default. If you'd like to change that, you can tweak the
=lispdir= variable.
- =infodir= :: Org Info installation directory. I like to keep the
Info file for development version of Org in a separate
directory.
#+BEGIN_SRC makefile
infodir = $(prefix)/org/info # Default: $(prefix)/info
#+END_SRC
- =ORG_MAKE_DOC= :: Types of Org documentation you'd like to build by
default.
#+BEGIN_SRC makefile
# Define below you only need info documentation, the default includes html and pdf
ORG_MAKE_DOC = info pdf card # html
#+END_SRC
- =ORG_ADD_CONTRIB= :: Packages from the =contrib/= directory that
you'd like to build along with Org. Below are the ones on my
/must-have/ list.
#+BEGIN_SRC makefile
# Define if you want to include some (or all) files from contrib/lisp
# just the filename please (no path prefix, no .el suffix), maybe with globbing
# org-eldoc - Headline breadcrumb trail in minibuffer
# ox-extra - Allow ignoring just the heading, but still export the body of those headings
# org-mime - Convert org buffer to htmlized format for email
ORG_ADD_CONTRIB = org-eldoc ox-extra org-mime
#+END_SRC
#+TITLE: My Blog
#+HUGO_BASE_DIR: ../
#+TAGS: these tags do not get globally applied to the posts
#+FILETAGS: alpha beta
#+FILETAGS: hyphened-tag
# Categories
#+FILETAGS: @cat1
# All tags in above #+FILETAGS lines will get collected.
# 1. Load `ox-hugo'
# 2. C-c C-e H A
* Super headline :super:
** Inheriting tags :gamma:delta:two__words:@cat2:
:PROPERTIES:
:EXPORT_FILE_NAME: inheriting-tags
:END:
If user specifies tags to the post subtree headline, those tags get
added to the set of default tags set in =#+FILETAGS= (and the ones
inherited). For the inheritance of tags from parent headlines and
=#+FILETAGS= to work, =org-use-tag-inheritance= needs to be set
appropriately if changed from the default value of =t=. These tags are
collected together and assigned to the Hugo =tags= front matter
variable for this post.
When setting categories via Org-style tags, prefix the tags with
"@". That "@" is used as a special character for =ox-hugo= to identify
those tags to be used as Hugo categories. This applies to categories
added as Org tags to headlines as well as =#+FILETAGS=.
** Overriding Org-style tags :this_tag_wont_apply:@this_cat_wont_apply:
:PROPERTIES:
:EXPORT_HUGO_TAGS: overriding
:EXPORT_HUGO_TAGS+: underscore_is_retained hyphenated-works
:EXPORT_HUGO_CATEGORIES: cat3 3__word__cat
:EXPORT_FILE_NAME: overriding-tags
:END:
By using =EXPORT_HUGO_TAGS= in the property drawer, Org tags in the
current headline ("this_tag_wont_apply") *and* the inherited one
("alpha", "beta", "hyphenated-tag", "super") will get overridden.
When setting categories via the keyword =#+HUGO+CATEGORIES= or the
subtree property =EXPORT_HUGO_CATEGORIES=, do *not* add the "@" prefix.
#+HUGO_BASE_DIR: ../
#+HUGO_SECTION: ./
#+HUGO_WEIGHT: 2001
#+HUGO_AUTO_SET_LASTMOD: t
#+TITLE: Writing Hugo blog in Org (File Export)
#+DATE: 2017-09-10
#+HUGO_TAGS: hugo org
#+HUGO_CATEGORIES: emacs
#+HUGO_MENU: :menu "main" :weight 2001
#+HUGO_CUSTOM_FRONT_MATTER: :foo bar :baz zoo :alpha 1 :beta "two words" :gamma 10
#+HUGO_DRAFT: true
* First heading within the post
- This post will be exported as
=content/posts/writing-hugo-blog-in-org-file-export.md=.
- Its title will be "Writing Hugo blog in Org".
- It will have /hugo/ and /org/ tags and /emacs/ as category.
- The /lastmod/ property in the front-matter is set automatically to
the time of export.
- The menu item /identifier/ is auto-set.
- The menu item /weight/ and post /weight/ if needed have to be
manually specified as shown above.
** A sub-heading under that heading
- It's draft state will be marked as =true= because of =#+HUGO_DRAFT:
true=.
With the point _anywhere_, do =C-c C-e H h= to export this whole file
titled /Writing Hugo blog in Org/ to a Hugo post.
The exported Markdown has a little comment footer as set in the /Local
Variables/ section below.
* Footnotes
* COMMENT Local Variables :ARCHIVE:
# Local Variables:
# fill-column: 70
# eval: (auto-fill-mode 1)
# eval: (add-hook 'after-save-hook #'org-hugo-export-subtree-to-md-after-save :append :local)
# org-hugo-footer: "\n\n[//]: # \"Exported with love from a post written in Org mode\"\n[//]: # \"- https://github.com/kaushalmodi/ox-hugo\""
# End:
+++
title = "Article 1"
date = 2017-07-19T08:34:29-04:00
draft = false
+++
First article.
This will land in `content/articles/` as the parent of this subtree
sets `EXPORT_HUGO_SECTION` to `articles`. Note that the theme needs to
define at least the `single.html`, either in the `layouts/_default/`
directory, or `layouts/articles/`, either in the Hugo base dir or the
theme dir.
+++
title = "Article 2"
date = 2017-07-19T08:34:22-04:00
draft = false
+++
Second article.
This will also land in `content/articles/` the same way.
+++
title = "Index"
draft = false
+++
Book 1 index.
This type of organization will generate this in the `content/`
directory:
```text
> tree book1
book1
├── chapter1
│   ├── _index.md
│   ├── section1.md
│   └── section2.md
├── chapter2
│   ├── _index.md
│   ├── section1.md
│   └── section2.md
└── _index.md
```
- [Chapter 1](/book1/chapter1)
- [Chapter 1 Section 1](/book1/chapter1/section1)
- [Chapter 1 Section 2](/book1/chapter1/section2)
- [Chapter 2](/book1/chapter2)
- [Chapter 2 Section 1](/book1/chapter2/section1)
- [Chapter 2 Section 2](/book1/chapter2/section2)
+++
title = "Chapter 1 Index"
draft = false
+++
Introduction for chapter 1
+++
title = "sub section 1"
draft = false
+++
Section 1 of chapter 1
+++
title = "sub section 2"
draft = false
+++
Section 2 of chapter 1
+++
title = "Chapter 2 Index"
draft = false
+++
Introduction for chapter 2
+++
title = "sub section 1"
draft = false
+++
Section 1 of chapter 2
+++
title = "sub section 2"
draft = false
+++
Section 2 of chapter 2
+++
title = "Post 1"
draft = false
+++
Post 1 contents
{{<figure src="/ox-hugo/gnu.png">}}
+++
title = "Post 2"
draft = false