Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Automatic header anchors not available?

Started by matteo 7 years ago · 12 replies · 1330 views
7 years ago

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:

HTML
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

7 years ago

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

YAML
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!

7 years ago

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.

7 years ago

Hi Paul.. cache cleared completely, same results.. using selector configuration. It is working but too much :) 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...

7 years ago

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

7 years ago

If I do that all the anchors disappear right?

7 years ago

OK disabled the plugin configuration, enabled in another page with

TXT
    enabled: true

but anchors are not visible..

7 years ago

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!

7 years ago

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:

YAML
anchors:
  active: false

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

YAML
anchors:
  active: true

Are you getting a different result with those settings?

7 years ago

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:

YAML
anchors:
  active: false

Without having to add

YAML
anchors:
  active: true

on all the other pages. Anyway, it is working

Thanks again for the information and testing

👍 1

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 103 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 187 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 63 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 259 1 year ago