Export org-roam backlinks with Gohugo

March 7, 2021
emacs, orgroam, orgmode

tags Org-mode Emacs Org-roam Since Org-roam export backlinks on Hugo no longer works, I found a solution to handle backlinks in Hugo itself. The following Hugo partial template will add backlinks to a note if any. {{ $re := $.File.BaseFileName }} {{ $backlinks := slice }} {{ range .Site.AllPages }} {{ if and (findRE $re .RawContent) (not (eq $re .File.BaseFileName)) }} {{ $backlinks = $backlinks | append . }} {{ end }} {{ end }} <hr> {{ if gt (len $backlinks) 0 }} <div class="bl-section"> <h4>Links to this note</h4> <div class="backlinks"> <ul> {{ range $backlinks }} <li><a href="{{ . ...

Ox-hugo export all roam to Hugo

June 4, 2020
emacs, orgmode, hugo, orgroam, roam

tags Emacs Org-mode Org-roam Export all org-roam files to Hugo markdown (this might take some time) From: jethrokuan/dots (defun benmezger/org-roam-export-all () "Re-exports all Org-roam files to Hugo markdown." (interactive) (dolist (f (org-roam--list-all-files)) (with-current-buffer (find-file f) (when (s-contains? "SETUPFILE" (buffer-string)) (org-hugo-export-wim-to-md))))) Adding an empty #+SETUPFILE: forces benmezger/org-roam-export-all to export the file.

Org-roam export backlinks on Hugo

June 4, 2020
orgmode, emacs

tags Org-mode Emacs Org-roam ❗️*Note:* This no longer applies (probably due to an upstream update). See the following note for another approach: Export org-roam backlinks with Gohugo Insert roam backlinks URL when exporting orgmode to HTML From: jethrokuan/dots (defun benmezger/org-roam-export-all () "Re-exports all Org-roam files to Hugo markdown." (interactive) (dolist (f (org-roam--list-all-files)) (with-current-buffer (find-file f) (when (s-contains? "SETUPFILE" (buffer-string)) (org-hugo-export-wim-to-md))))) (defun benmezger/org-roam--backlinks-list (file) (when (org-roam--org-roam-file-p file) (mapcar #'car (org-roam-db-query [:select :distinct [from] :from links :where (= to $s1) :and from :not :like $s2] file "%private%")))) (defun benmezger/org-export-preprocessor (_backend) (when-let ((links (benmezger/org-roam--backlinks-list (buffer-file-name)))) (insert "\n** Backlinks\n") (dolist (link links) (insert (format "- [[file:%s][%s]]\n" (file-relative-name link org-roam-directory) (org-roam--get-title-or-slug link)))))) (add-hook 'org-export-before-processing-hook #benmezger/org-export-preprocessor))

Org-roam Firefox bookmark

May 30, 2020
emacs, orgmode, roam, firefox

tags Org-mode Emacs Org-roam Org-roam has roam-protocol, which we can call throughout the system just like Org-mode Firefox bookmarks. Org-roam protocol supports specifying the roam template to use. Template is the template key for a template in org-roam-capture-ref-templates. More documentation on the templating system can be found here. These templates should contain a #+ROAM_KEY: ${ref} in it. Roam-ref protocol # Find and creates from with a specific ROAM_KEY ...

Org-mode Firefox bookmarks

May 30, 2020
emacs, orgmode, firefox

tags Org-mode Emacs Add the following scripts to call org-capture from Firefox Call capture template # The following calls capture template key n javascript: location.href = "org-protocol://capture?template=n" + "&url=" + encodeURIComponent(window.location.href) + "&title=" + encodeURIComponent(document.title) + "&body=" + encodeURIComponent(window.getSelection()); Without a capture template # If unspecified, the template key is set in the variable org-protocol-default-template-key. The following template placeholders are available: %:link The URL %:description The webpage title %:annotation Equivalent to [[%:link][%:description]] %i The selected text See: https:orgmode. ...

Hello, org-mode and hugo

April 23, 2020
blog, web
emacs, orgmode

Hello, world! This is my first post here. This blog is created using Hugo and Emacs org-mode. I am still busy migrating my posts from Asciidoc to org-mode, so this should take a bit of time.