Using Emojis in Categories

I use emojis a lot in categories

I am moving my design around and exposing categories on my posts

That part works - BUT the emojis seem to be all replaced with ?

Claude tells me that I should add unicodes to my CSS - does that sound right??

eg:

/* Pushpin */ span.callsit::before { content: "\1F4CC Posted in: " !important; }

this will be very annoying, needs a lot and not going to do - my hip pocket fix is to rename my categories back to text - but before I do that

Claude suggested:

Check if this is a Micro.blog theme encoding issue. Some themes force UTF-8 encoding that doesn’t play well with emoji. You might be able to fix it globally in the theme’s <head> instead of individual CSS rules.

My core template is hitchens - which is now 4 years out of date … bridge too far?

Time to bite the bullet and switch to a more modern design?

All and any help / direction welcome.

Many thanks.

Which theme are you using, the default? Sumo? I use TinyTheme (built in a similar manner) and I don’t have issues, I use emojis in my posts and on the main page… Is that what you mean?

Odd - i replied to this - but it doesn’t seem to be here - so going again.

I started with Hitchens. - but making lots of changes to it. That said - emojis all work well in titles and body - it is in categories I am having the problem.

According to Claude I can fix this - but either I need access to files that I don’t have because Micro.Blog / Hugo ‘injects’ certain behaviours - or just move off the platform and recreate somewhere else.

Does that sound right @sod ? If so - a bridge too far for this bear I feel.

I believe this is untrue. I think that you need to set preserveTaxonomyNames: true to your config. By default, Hugo strips special characters from taxonomies for URLs in some places.

1 Like

thank you Jason.

By default, Hugo strips special characters from taxonomies for URLs in some places.

this might be categories then? in micro blog currently about 50% of my categories contain emojis - none render - if there was a micro blog hosted site out there that does show emojis in categories - then i know I can do it - emojis throughout my site otherwise work fine.

Categories are taxonomies in Hugo (taxonomy is a broader term that includes categories and tags as well as custom stuff you can do).

Nope, that sounds like plausible-sounding Claude-generated nonsense to me. :sweat_smile: Am I right that on a post like this, you want category links to show up as 💬 Quote, but they’re currently showing up as ? Quote?

For a human to help troubleshoot why that is, they’ll need to see the relevant Hugo template.

1 Like

Many thanks - not sure if you were volunteering as that human - but just in case here’s where I think something is breaking

Category Name: :eye: Asides
Path: /categories/myasides

And I THINK the offending code in the template is this

{{ $Site := .Site }}
	{{ $categories := .Params.categories }}
	{{ if not $categories }}
		{{ $categories = slice "Asides" }}
	{{ end }}
	{{ if $categories }}
		<div class="cat-list">
			<span class="catlist">Posted in: </span>
			<span class="post-categories">
				<span class="article-category">
					{{ range $i, $e := $categories }}
						{{ if gt $i 0 }}
							<span>•</span>
						{{ end }}
						<a class="article-category-link" href="{{ $Site.BaseURL }}/categories/{{ $e | urlize }}">{{ $e }}</a>
					{{ end }}
				</span>
			</span>
		</div>

does that help? or need the whole thing?

My thanks in anticipation.

Yeah, that’s probably it. You could try switching that snippet out with one that’s known to work from the Sumo theme:

{{ if .Params.categories }}
{{ with .GetTerms "categories" }}
  <ul class="post-tags">
    {{ range . }}
      <li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
    {{ end }}
  </ul>
{{ end }}
{{ end }}
2 Likes

Thank you Sven - that did it. Back to the tweaks :slight_smile:

Claude suitable reprimanded - though I don’t know why I bother - he never listens!

2 Likes