Skip to content

Commit

Permalink
add: org-doomemacs-hugo post
Browse files Browse the repository at this point in the history
  • Loading branch information
tcluri committed Mar 23, 2024
1 parent 4a0d08d commit f39e187
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 0 deletions.
89 changes: 89 additions & 0 deletions content-org/all-posts.org
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,92 @@ All others: r+x = 4+0+1 = 5
user$ ls -la
-rwxr-xr-x 1 user user 2257 Jul 12 01:23 foo.py
#+end_src
* DONE Blog using org-mode in Doomemacs with Hugo :blog:org:doomemacs:hugo:
CLOSED: [2024-03-23 Sat 14:00]
:PROPERTIES:
:EXPORT_FILE_NAME: org-doomemacs-hugo
:END:
Hello! This is a post describing how anyone who uses Doomemacs can setup a blog and get writing.
To get started, familiarize yourself with what I'm assuming you know to do. If you don't, read on - there will be links you might find helpful. We are here to learn 😃
+ Know how doomemacs works to the extent that you can find where your init.el is and upgrade/sync from the commandline.
+ Know how to install the Go programming language on your linux machine and can install a go package(😉 Hugo)
+ Know how to use git well enough to commit/push your changes to a repository online - we'll be using Github
+ Know how to do a backflip once we are done, in your head is fine too

** Doomemacs
Doomemacs is a configuration framework for Emacs. You get many things out of the box - a starter pack of which you can disable/enable away options at your will.
Try to use the latest doom configuration, I tend to upgrade doomemacs once in 3 months or whenever it is necessary which usually means that a package got an upgrade or a bug that got fixed.
Once you try it, there is no going back to other configs/setups unless you are the person who loves your current Emacs config 🫡


Quick refresher of doomemacs commands, from the commandline:
+ ~doom upgrade~ - upgrades doom itself, fetching latest packages and their configuration.
+ ~doom sync~ - installs/removes packages and loads the packages by reading your doom config.


*** Enable org-mode and +hugo it
To install org-mode, go to your ~init.el~ file in your doom config folder. You can use ~SPC f p~ and then select by filename.

In it, enable org-mode and hugo under the ~:lang~ heading.
#+begin_src emacs-lisp
:lang
;; ... OTHER packages
;;nix ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel
(org +hugo) ; organize your plain life in plain text
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
#+end_src

This enables [[https://ox-hugo.scripter.co/][ox-hugo]] package which exports your posts in your ~.org~ file to markdown that is readable by Hugo(which we will install now).

If you are using standard Emacs config, this does quite a lot on the org side of things and you can see exactly what it is [[https://github.com/doomemacs/doomemacs/tree/master/modules/lang/org][here]].
** Hugo
Hugo is a static site generator written in Go. Hugo is great and everyone should use it. Let's get it installed on our machine using commandline,
this way we get to use the latest version and upgrade later on if needed. Before we do that we need to have the Go programming language installed.
Go to the install [[https://go.dev/doc/install][page]] and follow the instructions, they are clear and you can confirm it is installed using ~go version~ in your terminal, the
version should be ~1.20~ or greater since Hugo requires this.

To install Hugo after you have installed the Go language run the following command,
#+begin_src
go install github.com/gohugoio/hugo@latest
#+end_src
This is the standard version of Hugo and not the extended edition, if you need that refer [[https://github.com/gohugoio/hugo?tab=readme-ov-file#build-from-source][here]]

You can check that hugo is installed using ~hugo version~ at the commandline.
** Setting things up
Create an empty git repository on Github, the name of your repository should be ~<username>.github.io~
and clone it on your machine to a folder named ~blog~ or something else.

Now intialize hugo in the blog folder, use ~--force~ since it is a non-empty directory since it contains ~.git~ folder
#+begin_src
hugo new site --force blog
#+end_src

From inside the blog folder, ~cd~ into it, make hugo blog as a hugo module. This enables the blog's theme to be used as a module.
#+begin_src
hugo mod init github.com/username/username.github.io
#+end_src

Add the following lines to your ~hugo.toml~ (previously it was ~config.toml~) to add a theme. Select any you like, there are [[https://themes.gohugo.io/][lots]].
#+begin_src config
[module]
[[module.imports]]
path = "github.com/athul/archie"
#+end_src

On the command line, run the following
#+begin_src
hugo mod get -u
#+end_src

From here on, you can follow from the step #5 from ox-hugo's quickstart i.e "Appending lines to the site config": https://ox-hugo.scripter.co/doc/quick-start/

*** Github actions
To setup github actions to start deploying once you commit a post to your repository on Github i.e after writing your post in ~content-org~ directory and exporting it via ~ox-hugo~ using
~C-c C-e H H~, see [[https://gohugo.io/hosting-and-deployment/hosting-on-github/#step-by-step-instructions][here]].

** References
For references (or) further reading:
+ https://ox-hugo.scripter.co/doc/quick-start/
+ https://ridaayed.com/posts/howto-ox-hugo-github-pages/
114 changes: 114 additions & 0 deletions content/posts/org-doomemacs-hugo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
+++
title = "Blog using org-mode in Doomemacs with Hugo"
author = ["tcluri"]
date = 2024-03-23T14:00:00+05:30
tags = ["blog", "org", "doomemacs", "hugo"]
draft = false
+++

Hello! This is a post describing how anyone who uses Doomemacs can setup a blog and get writing.
To get started, familiarize yourself with what I'm assuming you know to do. If you don't, read on - there will be links you might find helpful. We are here to learn 😃

- Know how doomemacs works to the extent that you can find where your init.el is and upgrade/sync from the commandline.
- Know how to install the Go programming language on your linux machine and can install a go package(😉 Hugo)
- Know how to use git well enough to commit/push your changes to a repository online - we'll be using Github
- Know how to do a backflip once we are done, in your head is fine too


## Doomemacs {#doomemacs}

Doomemacs is a configuration framework for Emacs. You get many things out of the box - a starter pack of which you can disable/enable away options at your will.
Try to use the latest doom configuration, I tend to upgrade doomemacs once in 3 months or whenever it is necessary which usually means that a package got an upgrade or a bug that got fixed.
Once you try it, there is no going back to other configs/setups unless you are the person who loves your current Emacs config 🫡

Quick refresher of doomemacs commands, from the commandline:

- `doom upgrade` - upgrades doom itself, fetching latest packages and their configuration.
- `doom sync` - installs/removes packages and loads the packages by reading your doom config.


### Enable org-mode and +hugo it {#enable-org-mode-and-plus-hugo-it}

To install org-mode, go to your `init.el` file in your doom config folder. You can use `SPC f p` and then select by filename.

In it, enable org-mode and hugo under the `:lang` heading.

```emacs-lisp
:lang
;; ... OTHER packages
;;nix ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel
(org +hugo) ; organize your plain life in plain text
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
```

This enables [ox-hugo](https://ox-hugo.scripter.co/) package which exports your posts in your `.org` file to markdown that is readable by Hugo(which we will install now).

If you are using standard Emacs config, this does quite a lot on the org side of things and you can see exactly what it is [here](https://github.com/doomemacs/doomemacs/tree/master/modules/lang/org).


## Hugo {#hugo}

Hugo is a static site generator written in Go. Hugo is great and everyone should use it. Let's get it installed on our machine using commandline,
this way we get to use the latest version and upgrade later on if needed. Before we do that we need to have the Go programming language installed.
Go to the install [page](https://go.dev/doc/install) and follow the instructions, they are clear and you can confirm it is installed using `go version` in your terminal, the
version should be `1.20` or greater since Hugo requires this.

To install Hugo after you have installed the Go language run the following command,

```nil
go install github.com/gohugoio/hugo@latest
```

This is the standard version of Hugo and not the extended edition, if you need that refer [here](https://github.com/gohugoio/hugo?tab=readme-ov-file#build-from-source)

You can check that hugo is installed using `hugo version` at the commandline.


## Setting things up {#setting-things-up}

Create an empty git repository on Github, the name of your repository should be `<username>.github.io`
and clone it on your machine to a folder named `blog` or something else.

Now intialize hugo in the blog folder, use `--force` since it is a non-empty directory since it contains `.git` folder

```nil
hugo new site --force blog
```

From inside the blog folder, `cd` into it, make hugo blog as a hugo module. This enables the blog's theme to be used as a module.

```nil
hugo mod init github.com/username/username.github.io
```

Add the following lines to your `hugo.toml` (previously it was `config.toml`) to add a theme. Select any you like, there are [lots](https://themes.gohugo.io/).

```config
[module]
[[module.imports]]
path = "github.com/athul/archie"
```

On the command line, run the following

```nil
hugo mod get -u
```

From here on, you can follow from the step #5 from ox-hugo's quickstart i.e "Appending lines to the site config": <https://ox-hugo.scripter.co/doc/quick-start/>


### Github actions {#github-actions}

To setup github actions to start deploying once you commit a post to your repository on Github i.e after writing your post in `content-org` directory and exporting it via `ox-hugo` using
`C-c C-e H H`, see [here](https://gohugo.io/hosting-and-deployment/hosting-on-github/#step-by-step-instructions).


## References {#references}

For references (or) further reading:

- <https://ox-hugo.scripter.co/doc/quick-start/>
- <https://ridaayed.com/posts/howto-ox-hugo-github-pages/>

0 comments on commit f39e187

Please sign in to comment.