I am happy to share it with you and anyone else in the community.
I’ll put up both the code and a proper tutorial on my Ghost-O-Matic site in the near future.
In the meantime, if you have purchased a license for the DocuHub theme (which I can recommend you do through GumRoad) then I think I could properly send you a copy of the theme as it is installed on my demo at https://docuhub.ghost-o-matic.com.
I’ve been waiting for this update to make a new, clean integration, and to see if the developer might also add a TOC into the theme itself, which several of us have asked for. If he does not, then I might appreciate some chip-ins from those who want it sooner, to motivate me to package it up and make it available as a plugin.
So if you want you can wait and see what happens with that.
Otherwise, I can always be hired directly to do it.
Thanks your team for this detailed guide! But, I have an elementary question about it:
In what file(s) of Casper theme do I need to add code examples from the tutorial?
I speak about the code from the following sections: “Editing the post template”, “Styling the table of contents”, “Advanced styling”. If I am right, the code from “Editing the post template” I need to place in default.hbs before this piece of code (see the screenshot):
I tried to add the code from these sections in different combinations in default.hbs, /assets/css/screen.css and global.css, but couldn’t set up the same sticky ToC on my site as in your tutorial. Thank you for the details.
You are right about the default.hbs file, as it says in the tutorial. Which theme are you trying to customise? If it’s Casper have you tried following the readme guide on how to customise asset files? There’s more information in the GitHub readme:
David, I am trying to customize the default theme, Casper. I tried to add all these code pieces in default.hbs (css code by adding via ) and add css code in screen.css. But it desn’t work (test page is Правовой статус секрета производства (ноу-хау)). My files default.hbs and screen.css may be found here: https://yadi.sk/d/CfDCncrynTE_OQ
Hi, denvergeeks. My mistake. Your eyes went over my code sharply. Thanks for the note! Hope, I fixed it right, and now it is 1 instance. But, as I see, for unknown reason my ToC doesn’t work (links in it do not redirect to the corresponding headers). Will continue my search.
@counsel here is a clue to get you started troubleshooting why the links in your ToC are broken:
Compare the two screenshots below, careful to examine the blue highlighted lines. You will notice how the “href=” in your link is different from the “href=” in my link:
you don’t want the ToC to appear until the user scrolls down to the page content so you want it to be fixed below the featured image (which is taking up 400px at the top)?
you want the ToC not to get cut off, but remain visible above the footer at the bottom of the page?
Please post the URL of your live test page.
BTW - on my Vanilla theme demo below, I have a more subtle design on my ToC:
I can’t get it to work like it does on the slack site, where after you scroll a bit it stays at the top of the screen and then disappears when you hit the footer. Would love your thoughts!
Hi @beagle I checked your site, in your case the TOC is part of the post content and the best and easiest way to achieve what you want is to have the TOC as a sidebar, that way you could use position: sticky instead of fixed. (Slack also has it that way).
We also implemented something like that in our Auden theme, you can check it how it works here: Post with TOC