* Who Should Support Us
** Law Enforcement
** Environmental Protection
i get this in html:
<ul>
<li><a href="#headline-1">Who Should Support Us</a>
<ul>
<li><a href="#headline-2">Law Enforcement</a>
</li>
<li><a href="#headline-3">Environmental Preservation</a>
</li>
which is fine unless i want to add headings in between, because then the anchor ref changes. any links i’ve already setup within the website or given out, go to an incorrect place.
is there a way to make the headline ref absolute in the sense that #headline-1 would be #Who-Should-Support-Us
so the order won’t change the links themselves?
i have been using whatever comes with hugo, because i read somewhere that it is what we should use (can’t remember where, but something to do with blackfriday markdown).
however, this is the second time ox-hugo has been mentioned.
i would appreciate knowing what i really should use (if such a statement can be made) and possibly why.
ok k!
i’ve been reading up on ox-hugo and will try it tonight.
there is an item saying conversion from markdown isn’t necessary, which is understandable, but my site has been done in org-mode (then go-orged), so i presume most of it should work with no problem. however, the front-matter (from what i see on the ox-hugo site) is more extensive and a bit different.
for instance, i just have something like this:
type or paste code here---
title: Media
date: 2023-01-02T22:20:11-08:00
author: prauthor
description: Media articles and other items published regarding fireworks issues.
categories: [wellnes,erudite,operate]
tags: [fireworks,media]
which is quite different from the screenshots here.
not a big deal of course, but just wondering if there is a front-matter ‘converter’?
i’ve tried ox-hugo from both melpa and melpa-stable. one error i was getting in messages with the former was there was no ox-hugo-autoloads
right now i’m trying ox-hugo-0.12.2 from melpa-stable, but the C-c C-e doesn’t give me H H. however, i’m not getting the autoloads error.
i’ve have as stated in the quickstart
(with-eval-after-load 'ox
(require 'ox-hugo))
the only way i get anywhere is to
M-x load-file
~/.emacs.d/elpa/ox-hugo-0.12.2/ox-hugo.el
that at leasts gives me C-c C-e H H
and things seem to work, though, sometimes i get Cannot use unknown “blackfriday” back-end as a parent
(if i DO have the require 'ox-hugo code)
though i’d still like to get ox-hugo working, i’ve solved my issue with absolutizing the #headlines-x with the following script:
#!/usr/bin/env zsh
# absolutifies headlines for hugo generated html
# mechanism:
# take all #headline-x
# replace it with the actual headline wording (spaces -> -)
# example:
# <li><a href="#headline-1">Structure of Site</a>
# becomes
# <li><a href="#Structure-of-Site">Structure of Site</a>
# for the file
F=$1
# grab all the #headline-x and its description then split into array on \n
str=$(perl -ne 'print "$1|$2\n" if /<li><a href="(#headline-\d+)">(.+)<\/a>/' $F)
lines=(${(f)str})
# using assoc array (only because i've never tried it before)
declare -A aa
for l in $lines; do
# split into assoc array
aa=(${(s:|:)l})
key=${${(k)aa}#\#} #rm the '#' symbol
val=${(v)aa}
lnk=${val// /-} #replace sp with -
#echo "$key -> $val -> $lnk"
# do the replacements
perl -pi -e "s/$key/$lnk/g" $F
done
exit
the files i go after (just because of the way my site is setup) are the index.html in updated public/ dir after we hugo the content/ dir.
i use find to pick out the index.html files in the specific directory i’m interested in and feed these to the above script, huhd.sh:
so the ‘Human Safety’ link in the toc of this page:
http://towardsfreedom.com/ictvity/ethology/fireworks/helpful-alliances/#Human-Safety
was changed from being the sometimes inconvenient
http://towardsfreedom.com/ictvity/ethology/fireworks/helpful-alliances/#headline-5
and if it changes position later on to say #headline-9, i won’t have to rewrite all the links pointing to it.
imho, it would be nice if this sort of absolutization of headings could be added to hugo, but this script does the job for now.