Hello,
I already had this render-heading code that the user @jmooring kindly provided to me, which allows me to increase the size of each heading by one.
That’s a CSS question (and perhaps concerning accessibility, too). From a first glance it looks syntactically ok, if a bit too complicated for modern CSS. And hover doesn’t work well on mobile devices.
Thank you. I was interested in the _markup/render-heading.html part. For me it looks a bit weird to have an anchor element with no content inside it. I mean when it comes to the HTML markup itself.
Then that’s a HTML question. An empty a element indeed is not ideal (perhaps not even allowed). Just embed the hx in the a. Or the Text. The net should be full of examples.
Thank you. I know that some empty elements can be addressed with an ARIA attribute. Anyway, I was curious if render-heading.html is the file that should handle this, meaning I was interested if Hugo is supposed to manage it there and if it’s okay to modify that file.
That’s a CSS question (and perhaps concerning accessibility, too).
I think CSS is complicated on its own by design. The hover trick I use is something I often see in hamburger menus, nothing out of the ordinary.
I know I’ve asked quite a few questions here on the forum. I’m a bit rushed to finish my page right now and I’m also feeling a bit stressed with a family member being sick. However, I definitely want to take the time to read the manual and educate myself because I know that asking questions doesn’t make sense without understanding things myself. I took a course by Todd McLeod on Go, but that was two years ago, and without practice, I’ve forgotten a lot. Also, Hugo has its own way of doing things. I’ll need to start reading the Hugo manual and approach it systematically.
you use a render hook ro render headings.
So the best place is to add that there. Otherwise you may ger side effects if you distribute the code to multiple locations.
you already have a custom code just for you.
So the answer is yes. You had that question before. If you need a custom version of a standard file. Create a copy in your local layouts and adjust.
You may find a JS approach more flexible and capable, namely AnchorJS.
git clone --single-branch -b hugo-forum-topic-52165 https://github.com/jmooring/hugo-testing hugo-forum-topic-52165
cd hugo-forum-topic-52165
npm ci
hugo server
It works really well out of the box, handles heading elements that exist in content and in templates, and is not restricted to the Markdown content format (i.e., works with AsciiDoc, Emacs Org Mode, HTML, etc.).
And you can add an anchor to any element, not just headings.
I downloaded the anchor.js and it’s imported. I checked that in the browser’s view source. I try to call it from custom.js, where I put all my own JavaScript code, and it says:
It’s like when I’m trying to access a variable that isn’t in the global scope. It’s strange. Importing with NPM would probably be easier, but I currently have everything imported as separate files and would prefer to keep it that way.