Automatic header anchors not available?

Hi all,

very simple question. It seems to me that all the headers (doesn’t matter if # Header1m, ## Heaader2, …) don’t have an automatic anchor in html code. I don’t know if this is the expected behavior…

To refer to a specific subsection from one page to another I have to set a named anchor and then I can call it:

page1
.....
.....
## My title <a id="my-title"></a>
....
....

page2

Have a look at [my title page](page1#my-title)

Am I missing something?

Cheers and thanks

Matteo

Hi @ghtmtt, I think that the Anchors Plugin might be just what you are looking for🙂 https://github.com/getgrav/grav-plugin-anchors

Hi @paulhibbitts thanks for the answer

I tried the plugin and it seems working without having to add anything :slight_smile: great! Maybe I’m blind, but maybe adding a mention to the plugin here https://learn.getgrav.org/15/content/markdown#named-anchors is a good idea.

Thanks again!

1 Like

wait I’m facing maybe a small issue… I want to disable the anchors on the home page (modular structure). I’ve put in all files of the home page modular structure

anchors:
    active: false
    enable: false

but still the anchors are showing in all the 01_hero, o2_highlights… files in all the languages. It is a little bit annoying. Imagine the demo site here http://demo.hibbittsdesign.org/grav-open-publishing-quark/ and see the anchors where My Open Publishing Space title appears…

are there any workaround for that?

Cheers and thanks again!

Glad the Anchors Plugin is of help! A few ideas - make sure you clear the cache while testing (or even better turn off both caches while developing the theme) in system.yaml file, and also I’d try out the selectors option to see if you can get the result you want: https://github.com/getgrav/grav-plugin-anchors#configuration

I have only used the Anchors Plugin a bit myself.

Hi Paul… cache cleared completely, same results… using selector configuration. It is working but too much :slight_smile: I mean: the titles overlapping the image are h1, h2 and h3 I can remove them from the selector, but (the plugin is working well) also all the other anchors from all the other pages disappear… and that’s not what I’d like to happen…

strange that the plugin configuration is not working by excluding the anchors from some pages…

Hi @ghtmtt, did you disable Active on the Plugin settings page?

If I do that all the anchors disappear right?

OK disabled the plugin configuration, enabled in another page with

    enabled: true

but anchors are not visible…

I think you need to use active vs. enabled? https://github.com/getgrav/grav-plugin-anchors#configuration

Hi Paul… tried with only active, only enabled or both (of course set to false). But nothing.

Actually the way around is working: disabling the plugin from the configuration page and enable the anchors in all the pages. Do you think it is a bug and I should file a ticket?

Thanks for the reply and support!

Hi @ghtmtt, happy to help out🙂

I just tested the Anchors Plugin and to disable the plugin (i.e. Anchors) on a single page this worked:

Plugin Settings:
Enabled: true
Active: false

Page Frontmatter:

anchors:
  active: false

Note that to then have Anchors displayed on a page you need this:

anchors:
  active: true

Are you getting a different result with those settings?

Nope that’s also what I have. I’m just wondering why it isn’t working in the other direction, like:

Plugin Settings:
Enabled: true
Active: true

Page Frontmatter:

anchors:
  active: false

Without having to add

anchors:
  active: true

on all the other pages. Anyway, it is working

Thanks again for the information and testing

1 Like