And back to exporting obsidian to hugo
Obyde needs 3.8 and fails otherwise, new OS maybe time for new ways to convert. There are many actually. Some active mantained and expandable.
For later:
- devidw/obsidian-to-hugo: Process Obsidian notes to publish them with Hugo. Supports transformation of Obsidian wiki links into Hugo shortcodes for internal linking. looks especially nice.
- Publishing Obsidian vault with Hugo - Sagar Behere lists all the other ways and is really detailed
- (Also on hugo A Hugo Survival Guide is a neat thing I’ll read sometime)
So
obsidian-to-hugo doesn’t support assets/images :( Leaving only ukautz/obsidian-meets-hugo: Command line tool to export Obsidian Vault into Hugo published website for me.
- preserves Obsidian directory structure — nice
- not recursive by default
- doesn’t create
_index.md
files, and converts existing ones in Obsidian to-index.md
- pchr8/obsidian-meets-hugo: Command line tool to export Obsidian Vault into Hugo published website forked and did my first go programming to fix this
- doesn’t support folders, but one can filter by tags — good that I used both since the beginning!
- for multiple tags a “list” is possible — and apparently that’s
-i tag1 -i tag2 -i tag3
1
- for multiple tags a “list” is possible — and apparently that’s
Current CLI:
go run cmds/omh/main.go --obsidian-root=../public_obs/ -R --hugo-root=../dtb/ --sub-path= -i=uni -i=zc/it -i=zc/rl
Onwards
- 3 refs not found
- I don’t understand why hugo says “ref … page not found” - support - HUGO:
Is linksphoto.md unpublished (draft, expired, or future)? Or, to put it another way, what happens when you run
hugo server -DEF
? fixed for me! hardcoded hugo-format refs in obsidian broke because now different names — converted to real obsidian links and this fixed the remaining ones
- I don’t understand why hugo says “ref … page not found” - support - HUGO:
- cyrillic names now unsupported?
- 220407-2246 Чебуреки etc.
- damn.
- It’s the same
var insane = regexp.MustCompile(`[^a-zA-Z0-9\-]`) func Sanitize(in string) string { return insane.ReplaceAllString(in, "") }
- w/ chatGPT, changed regex to
[^a-zA-Z0-9\-\p{Cyrillic}]
— now it does upper+lowercase cyrillics — so now it’s220407-2246-Чебуреки.md
in the md filename, but the URI has it lowercased. - Relevant:
disablePathToLower
in config2 — not changing because cool URIs don’t change and this was the default for years on this website
- Images are broken
![2024-05-13-182935_1304x442_scrot.png](//assets/2024-05-13-182935-1304-x-442-scrot.png)
- …
//assets
alrighty… - Docu: Static files | Hugo
-
By default, the static/ directory in the site project is used for all static files (e.g. stylesheets, JavaScript, images). The static files are served on the site root path (eg. if you have the file static/image.png you can access it using http://{server-url}/image.png, to include it in a document you can use !
[Example image](/image.png)
). - you can have multiple such directories
-
- Ah — maybe it’ll work when uploaded to my website, where
/xxx
will refer to the website and not my local install - If I manually fix
//assets/..
to/assets
(one slash) then it shows up nicely locally - In
omh.go
this happens:return fmt.Sprintf("[%s](/%s/%s)", title, c.SubPath, target)
- AH it’s because of my empty subpath directory argument — if I pass something then everything works. Oh GodDAMN it.
- OK this fixes it. And I hope creates no more problems.
if c.SubPath == "" { return fmt.Sprintf("[%s](%s/%s)", title, c.SubPath, target) } else { return fmt.Sprintf("[%s](/%s/%s)", title, c.SubPath, target)
- Debugging a notes called
_index
I realize that it takes Hugo frontmatter title from note title, which in turn is the filename, NOT the obsidian file frontmatter title :(- problem because my layouts rely on a magic constant in some directories…
- I hope it’s my last fix.
// Keep title in Obsidian front-matter as note title if it's there (a la obyde),
// otherwise use Obsidian filename for this (standard behaviour).
oldTitle := hugo["title"]
if oldTitle==nil {
log.Warn("No title in front-matter, using filename in ", note.Title)
// must have title
hugo["title"] = note.Title
} else {
log.Warn("Using frontmatter title for ", oldTitle)
}
-
had to figure this syntax out based on other github issues: StringSlice behavior different for command line flag and environment variable · Issue #380 · spf13/viper ↩︎