Open utterances-bot opened 3 years ago
Thanks!
Thanks Silvia for this excellent writeup! I was wondering if you had any suggestions on how to implement to "On This Page" table of contents that you have in the sidebar? From what I can tell, this is implemented using some additions and tweaks to the /layouts directory?
Hi @kwanlin! Thanks for your question -- it will be the first one I answer using Utterances! 🔮
You are correct about the table of contents, it's implemented as an HTML partial in the /layouts
folder. I'll outline some steps below:
Step 1. Create a custom partial for the table of contents (i.e. post-toc.html
) like I do here:
Step 2. Copy the single-sidebar.html
file from the themes/hugo-apero
layouts folder into your own layouts folder. In my case:
Step 3. Insert the table of contents partial from Step 1 into the single-sidebar.html
layout using:
{{ partial "shared/post-toc.html" . }}
Seen in context below:
Step 4. Tweak the table of content settings in the config.toml
file to suit your preferences:
For another very similar implementation you can explore Alison Hill's single-sidebar.html and sidebar-toc.html setup.
There are some extra things going on with my site that make it so the table of contents styling changes as the reader scrolls down the page. The implementation is a little clunky at the moment (I don't know JavaScript!) but I linked to some resources in https://github.com/spcanelon/silvia/issues/23#issuecomment-842515487 to go along with the commits if you're interested 🔍
Thank you for the detailed response! It looks like the two things that were tripping me up were:
config.yaml
file (not too sure why it's not a .toml, I'm guessing I checked some option when I was getting things set up with blogdown)contents/blog
section prior to the addition of the table of contents, which seems to have gotten in the way of the table of contents rendering properly when I subsequently made the changes.Thanks for this post !! Unfortunately, I receive the error aforementioned ( Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: _default/single.html:3:8: executing "_default/single.html" at <partial "head.html" .>: error calling partial: execute of template failed: template: _internal/schema.html:24:82: executing "_internal/schema.html" at <.Params.tags>: range can't iterate over Data Science).
But everything was ok until I decided to update blogdown to 1.6 version and Hugo to 0.89.4 version and now I can not update the site. Any idea about how to fix it?
Thanks in advance !!
Hi @Tai-Rocha! Thanks for reading the post. Blogdown and Hugo issues can be tricky to figure out! Here are some questions to consider:
Excelent post! I'm following to migrate my web site. When I move my blog content I found that some of my post don't show on the list (actually the blog only show one). I have to remove the type parameter on the YAML to all the post. Sharing this here jus in case some one else found this issue.
When transferring my old posts I noticed that .Rmd files are directly rendered to .html files thus any Apero specific theme settings are not included. Converting the files to .Rmarkdown fixed the issue. Also sharing in case somebody else runs into the same problem.
I did the deploy with different steps:
That avoid the merge conflicts and has to delete the files one more time. My new website: https://yabellini.netlify.app My old website was left in the master branch: https://master--yabellini.netlify.app/ (I probably should change the name :-) )
Gracias por este tutorial, me ayudó muchisimo!
Hello Hugo Apéro: Converting a Blogdown Site from Hugo Academic | Silvia Canelón
A tutorial on how to take your personal Hugo Academic/Wowchemy website and convert it to the Hugo Apéro theme
https://silvia.rbind.io/blog/2021-hello-hugo-apero/