Content structure

Following on the comments from Evgeny to my post, I have changed the directory structure for my posts.

Up until now, I had a directory blog which was full of directories, such 20220112-content-structure, where the first six digits represented the date. In that directory I then had an file with the content of my post.

Now I have moved to a hierarchical date structure, where the content for that post is now in blog/2022/01/12/content-structure/ I wrote a quick and dirty shell script to move all the posts.


# move through my content a rename it all -- let's just do my blog
cd content/blog
for SOURCE in [12]*
    echo Processing $SOURCE


    if [ ! -d $YEAR ]
        echo mkdir $YEAR
        mkdir $YEAR
    if [ ! -d $YEAR/$MONTH ]
        echo mkdir $YEAR/$MONTH
        mkdir $YEAR/$MONTH
    if [ ! -d $YEAR/$MONTH/$DAY ]
        echo mkdir $YEAR/$MONTH/$DAY
        mkdir $YEAR/$MONTH/$DAY

That is all well and good, however quite a few of my posts link to other posts using Hugo's refref. Nothing that a quick find and sed cannot fix. I also used this as an opportunity to move from using relref to ref (I don't know why I was using relref in the first place).

find content -type f -exec grep -l " relref " {} \; | xargs sed -i 's/ relref \"[0-9]*-/ ref \" /g'

That left me with a few posts with 'refs' to ambiguous names. For example I had {{ ref "walking" }} which could map on to several posts, such as:

  • /blog/2004/06/16/walking
  • /blog/2005/05/29/still-walking-after-all-this-time
  • /blog/2009/03/04/walking-the-dogs

For the eight posts that had this type of problem, I then manually fixed them up, e.g., changing 'walking' in the above example to be {{ ref "/blog/2004/06/16/walking" }}.

Job done! It took longer to write this post than to do the conversion.

Now to go back and try using the -cd option of Evgeny's webmention-io-backup tool. That will be a longer task as I need to re-do how I process webmention 'replies'. I think I will split out 'mentions' from 'replies' … let's see what happens.

If you webmention this page, please let me know the URL of your page.

BTW: Your webmention won't show up until I next "build" my site.

    Show all the shares aka