Hugo in Termux with Obsidian
By JC
- 3 minutes read - 564 wordsInstalling Hugo
I am planning to install Hugo and deploy my obsidian files.
I a thinking it will not work on Termux I might need to use Proot Distro
Following this method:CGO_ENABLED=1 go install -tags extended,withdeploy github.com/gohugoio/hugo@latestfrom this source source
Update Above is not working.
**
Termux pkg installation
I manage to install Hugo with this command:
pkg install hugo
- To create hugo site:
hugo new site quickstart
- To copy Theme:
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
- Append in configuration:
echo "theme = 'ananke'" >> hugo.toml
- Run Hugo
hugo server
Copy Obsidian Files
Here is the command:
rsync -av --delete ~/SyncthingAndroid/Obsidian/notes/ ~/hugo-test/quickstart/content/posts
Editing Config for Website in hugo.toml
baseURL = 'https://blog.webdev.website/'
languageCode = 'en-us'
title = 'Jc Personal Blog'
theme = 'ananke'
[services.disqus]
shortname = 'JC'
[params]
commentoEnable = true
# site_logo = "/images/jclogo.png"
show_reading_time= true
In this config for Theme Ananke, I was able to add comments and change logo. In adding comments need to be registered at commento.com
Alternate Way Link Files from other Folder
add this in hugo.toml:
[module]
[[module.mounts]]
source = '../../SyncthingAndroid/Obsidian/posts/'
target = 'content'
I don’t need to run rsync again. Since it will be automated whatever I add in my Obsidian.
I set an other project but show_reading_time = true is not working. I figured out needs to set [params] at the top
Now another problem arise as I mention on earlier I manage to link my Obsidian but the author and reading time is not showing. The reading time works earlier if the .md files are inside the contents under Hugo project folder. When I move to Obsidian Author is not showing .
Solution with the help of chatgpt: Under themes/ananke/layouts/page/single.html
I added this code copied from _default/single.html
{{ with .Params.author | default .Site.Params.author }}
<p class="tracked">
{{ $.Render "by" }} <strong>
{{- if reflect.IsSlice . -}}
{{ delimit . ", " | markdownify }}
{{- else -}}
{{ . | markdownify }}
{{- end -}}
</strong>
</p>
{{ end }}
{{/* Hugo uses Go's date formatting is set by example. Here are two formats */}}
{{ if not .Date.IsZero }}
<time class="f6 mv4 dib tracked" {{ printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safeHTMLAttr }}>
{{- .Date | time.Format (default "January 2, 2006" .Site.Params.date_format) -}}
</time>
{{end}}
<span class="f6 mv4 dib tracked"> - {{ i18n "readingTime" .ReadingTime }} </span>
<span class="f6 mv4 dib tracked"> - {{ i18n "wordCount" .WordCount }} </span>
Somehow it works. It show reading time, and Author. This is somehow a neat trick but I think it is not best since the layout will be affected. I notice the design of the single page is not complete unlike the other way where I need to copy from obisidian instead of linking to it with module.
**I prefer the copy files from Obsidian instead of linking from Obsidian **
Add images in Obsidian and Display in Hugo
I manage to add images after searching and asking chatgpt.
Add images under blog folder in Obsidian.
Add this code in obsidian:

Hugo and Obsidian Copy Files
This script will watch changes folder and will auto copy files when changed happen in Obsidian blog folder to Hugo project folder
- Install first
entr:
pkg install entr
- Create script and name it
watch_copy.bashor any name:
find ~/SyncthingAndroid/Obsidian/blog/ -type f | entr -d rsync -av --delete ~/SyncthingAndroid/Obsidian/blog/ ~/hugo-test/quickstart/content/posts
- then need to change permission:
chmod x+u watch_copy.bash
- Run script
./watch_copy.bash