Skip to content

Commit

Permalink
[PUBLISHER] Merge #115
Browse files Browse the repository at this point in the history
  • Loading branch information
pbjorklund authored Nov 14, 2024
1 parent 20c0f20 commit b7d8cb8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions content/posts/publishing-this-blog-from-obsidian.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ And using this WikiLinks to MDLinks seems to work well.

Then I do bit of a hackish solution so it can find the linked files `<img alt="Pasted image 20241109091858.png" src="Pasted%20image%2020241109091858.png">` and push them directly to the `static` directory.

## Aaand a small patch for hugo
When using the Enveloppe plugin to export notes to Hugo in the way we are above, the `[[links]]` in our notes are converted to Markdown links without a leading `/`. This means that image paths generated for our content, like `![Image](image.png)`, are relative paths without the leading slash.

In Hugo, when these relative image paths are rendered into HTML without a leading `/`, they become relative to the current page's URL. I.e it tries to find images under www.pbjorklund.com/post/our-post-name/image.png instead of directly under www.pbjorklund.com/image.png.

So to "fix Hugo" to work with our wonky setup above we do this in the root of our hugo repo to create a new render hook:

```bash
mkdir -p layouts/_default/_markup && cat > layouts/_default/_markup/render-image.html <<'EOF'
{{- $src := .Destination -}}
{{- if not (hasPrefix $src "/") -}}
{{- $src = printf "/%s" $src -}}
{{- end -}}
<img src="{{ $src }}" alt="{{ .Text }}" />
EOF
```

## Actually writing posts

Now for actually writing the posts I just create a new note in my blog folder and then insert my "hugo frontmatter template" like so:
Expand Down

0 comments on commit b7d8cb8

Please sign in to comment.