Dynamically generating OG images

Paging @manton or @sod if either of you know whether this is possible to do in Micro.blog, asking for a friend of course… :wink:

This workflow has the generated images being placed underneath the location of the post, but I’m not sure the required access is available with MB for this to even work.

I’m not sure what you mean by the location of the post, but I believe everything in there is possible on Micro.blog. Image filters were added to Hugo in 0.60.

Sorry, what I meant by location was the placement of the physical image file in relation to the post file. So in the case of the URL, it’s located at <permalink>/og.png. But in Micro.blog’s case I’m not sure this would work, since uploads normally go to the specific folder, rather than with the post itself. And unless I’m misunderstanding, MB permalinks are based on an HTML file as opposed to a folder location that could have sub content underneath.

This line generates the file. Hugo supports colocating images and posts, so I suspect this would work, but you could also instead put it in your uploads folder and name it something like {{ .slug }}_og

{{ $img = resources.Copy (path.Join .Page.RelPermalink "og.png") $img }}
1 Like

I wasn’t able to get it to work.
The pages refused to render after creating the image.


I added the following as a partial

{{- if .IsPage -}}
{{ $base := resources.Get "og_base.png" }}
{{ $img := $base.Filter (images.Text .Site.Title (dict
    "color" "#000000"
    "size" 52
    "linespacing" 2
    "x" 141
    "y" 117
{{ end }}

[deleted coz not pertinent]

Nope— this is about trying to dynamically generate an image on a page, not whether the timeline then uses that OG content.

@manton anything strange about disk volume access on blog builders that might explain this?

Would it be possible to see an error log? I have it running on my test blog mandaris-test.micro.blog
@manton @help