Inserting a named anchor

Hi, Maybe this is just too obvious in Ghost 2.0 (Pro):

I want html anchors with some of my blogpost sub-headings, so I can link to that page position from elsewhere.
I try to insert a html-card and enter <A NAME=chapter2></A>
This is inconvenient as I would have to click the card to see what’s there. (maybe better if I revert and proceed with markdown-cards?)
With casper 2.7 theme this is actually awkward as the anchor position ends up under the banner.

Ideas?
Thanks.

If you create sub-heading with (highlight text + right click + heading icon),
then your new sub heading gets ID value set by content.
So if you insert a new heading called “My new heading” the ID is set to:
<h2 id="my-new-heading">My new heading</h2>
That means you can insert a anchor link pointing to the new heading this way:
<a href="#my-new-heading">my new link</a>
or (highlight link text + right click + link icon) and set value to #my-new-heading

5 Likes

Thanks Joakim,
Forgot to look in the source!
This feature could be quite useful.

The generated anchors are undoubtedly fragile for heading edits, but on the other hand very easy to relate to.
The debugger/inspector is telling me that special characters like my Scandinavian letters are replaced by dashes - fair enough.
Some links to these anchors/headings becomes hidden behind the dropping Ghost menu banner (don’t know the correct term), some do not trigger the banner and are displayed in the top as desired. Can’t figure out when/why. That’s a showstopper for now.

This is a common problem when using anchor-tags and fixed headers. It also seems like other people has this problem with Casper theme. See https://github.com/TryGhost/Casper/issues/471
Maybe the Casper-theme-authors in this forum can tell you the best way to do it.
Anyway Its should be easy to solve this with some CSS. An example can be found here https://www.caktusgroup.com/blog/2017/10/23/css-tip-fixed-headers-and-section-anchors/
Another solution is changing to a better theme: https://marketplace.ghost.org/

1 Like

Thanks again Joakim,
I agree that the CSS anchor-offset approach would generally provide a good fix, but in this particular case the banner drops in just some of the cases and the page would be scrolled a bit far down in, say, in half of all cases.

Paying for themes is really no problem and probably a great mechanism to develop the platform.
But I felt that the Casper theme was just what I needed to start out from, with a fair and balanced space for pictures and text, and not too much spacious design elements.
I have started with CMSes where I was kind of forced into switching themes before having much experience (like now), with no good migrations guides or content-based previews, and awkward rollback.
If someone can point me to assuring theme migration docs I would be very happy. (hmm, a theme with light-boxes that peek into my SmugMug albums?)

Being rather new to Ghost, I had another spin around.
Will not use links to sub-headings for now, as there’s apparently no good and straightforward fix to the banner-hiding issue.
The theme marketplace isn’t very mature. For instance, no list filter on Ghost version supported, or how tags are honored. Themes looks like a developer activity. Maybe I’ll spend some time in the future to get aquainted.
For now, I just needed to create and publish content, that’s why I went with the Pro team subscription.
Also, can’t find any guarantee that installing and switching themes is “non-destructive”. If a theme by its installation modifies content (e.g. remove or rearrange tags), then I won’t even be able to preview and revert safely.

Themes don’t have permission to edit Ghost’s data!

I can generally think of a couple of potential issues with platforms switching themes. (And I have seen it elsewhere.)
One of them is data produced with one theme, getting a slightly different meaning with another theme.
I do believe it is unlikely with Ghost though. I will know if I look closer at theme development.
But I can’t understand why it is not spelled out in the docs that you can switch back and forth between themes completely free from worry.
If you can.

Quite a few of the docs pages have a button to give feedback! It’s really easy to accidentally gloss over a concept :wink:

Because you can’t. Nothing is free from worry or behavioural edge cases, and themes are no exception. We would never ‘spell out’ or claim anything as being ‘completely safe and problem free’ - ever.

Ok, I should have quoted “spelled out”. Didn’t mean to have anyone guarantee against bugs or shortcomings of system design.
I was thinking about a more pragmatic approach. For instance if the theme switching has been specially tested with the current platform.

I see that I have a free publication slot with my Pro subscription and will try testing that way. (I’m a bit reluctant to rely entirely on a point in time backup using Ghost export and import, and I didn’t want to spend time figuring out why I couldn’t keep a ready made Ghost container running in Azure)

No problem, I have also asked Pro email support.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.