# Why are anchor links not available to pages?

**URL:** <https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752>\
**Category:** Uncategorized\
**Created:** [May 17, 2023, 10:01am UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752 "2023-05-17T10:01:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [May 17, 2023, 10:01am UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/1 "2023-05-17T10:01:42Z")

</div>

I noticed in the documentation that `insert_anchor_links` are only available for sections. Is that, and , if so, why?

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [May 17, 2023, 12:44pm UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/2 "2023-05-17T12:44:43Z")

</div>

It applies to all pages in that section.

---

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [May 17, 2023, 1:09pm UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/3 "2023-05-17T13:09:40Z")

</div>

Ahh that makes so much more sense than what I thought. Ok, thank you.

---

<div class="post-metadata">

**Author:** ![balu](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/balu/32/1295_2.png) [@balu](https://zola.discourse.group/u/balu)\
**Post date:** [August 28, 2024, 9:35am UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/4 "2024-08-28T09:35:51Z")

</div>

That does not seem to be the case for me?

```auto
content/projects/_index.md # has `insert_anchor_links = "right"`
content/projects/website/index.md # gets anchor links
content/projects/website/markdown.md # does not get anchor links 

```

Why does the `markdown.md` page not get anchor links?

I’m also confused why I can’t seem to set it globally and/or individually on each page, but only for sections.

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [September 24, 2024, 7:58am UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/5 "2024-09-24T07:58:17Z")

</div>

Hey Balu, I’m going to take a guess here as to why you’re seeing this.

`website/index.md` is a page under the root section `/`. Pages are allowed to be inside a directory for collocated assets, but they must be named `index.md` within that directory. This would make the url path `/website`. So it’s a page, under the root section. It’s the same thing as if you named that file `/website.md`.

On the other hand, `website/markdown.md` is a page without a section. There is no section inside the `website` directory. This is called an “orphan page”. From the [documentation](https://www.getzola.org/documentation/content/section/#section):

> A section is created whenever a directory (or subdirectory) in the `content` section contains an `_index.md` file. If a directory does not contain an `_index.md` file, no section will be created, but Markdown files within that directory will still create pages (known as orphan pages).

So basically because it’s an orphan page (a page without a section) it isn’t inheriting the rules of the root section.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![balu](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/balu/32/1295_2.png) [@balu](https://zola.discourse.group/u/balu)\
**Post date:** [September 24, 2024, 9:15am UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/6 "2024-09-24T09:15:30Z")

</div>

Thanks for your reply, but I am still confused.

The pages I was talking about were not under the root, but under their own section `projects/`. But I guess this doesn’t make a difference.

I am still not sure how to get the “orphaned page” to get anchor links. Setting `insert_anchor_links` in the page itself doesn’t work.

If I rename `website/index.md` into `_index.md` to make it a section, the `markdown.md` is not an orphan anymore and will get the anchored links (if enabled in `website/_index.md`, it does not seem to inherit from `projects/_index.md`)

But I am losing `date` and `updated` front matter since it is not a page anymore, but a section. Plus it is not listed as page the `/projects` section anymore, because well - it isn’t a page.

I don’t understand why `insert_anchor_links` is not a setting for the page itself? It only affects this page’s generation anyway?

---

<div class="post-metadata">

**Author:** ![spence](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/spence/32/1022_2.png) [@spence](https://zola.discourse.group/u/spence)\
**Post date:** [September 25, 2024, 9:52am UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/7 "2024-09-25T09:52:58Z")

</div>

Wups about the projects/ vs /, thanks for correcting my error. 😬

Yes the `insert_anchor_links` won’t work for pages unfortunately.

Regarding the rest of your reply, the answer you seek may be in the [section front matter](https://www.getzola.org/documentation/content/section/#front-matter) documentation. Specifically, it seems that based on what you’re asking you might be able to use the `render = false` setting with your `website` section’s front matter, i.e. `website/_index.md`.

From the documentation:

> ```toml
> # If set to "true", the section homepage is rendered.
> # Useful when the section is used to organize pages (not used directly).
> render = true
> 
> ```

However, you can’t have `index.md` file and a `_index.md` file in the same directory in Zola. To keep the same directory structure and go around this limitation you could rename your website page `projects/website.md`, and then put an empty section to organize all the pages nested under website, i.e. `projects/website/_index.md`. This will give you the url structure that you want, while keeping everything a page, and allowing the anchor links to be organized by sections.

(btw you can also take this a step further and mark the website section as `transparent = true` and it will just inherit everything from the projects section, I think).

The last thing I’ll add is that although I think zola v2 is planning on eliminating sections vs pages as concepts (which is probably the biggest source of friction among new users), it’s not such a terrible way to do things. This is just my opinion of course, and you do you, but the most natural way to solve your problem would be to make website an actual section, and sort of embrace the design, where pages are meant to only be the “leaves” of the tree.

Anyways, hopefully that solves your problem?

---

<div class="post-metadata">

**Author:** ![balu](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/balu/32/1295_2.png) [@balu](https://zola.discourse.group/u/balu)\
**Post date:** [September 25, 2024, 8:45pm UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/8 "2024-09-25T20:45:01Z")

</div>

> [@spence](#):
>
> Wups about the projects/ vs /, thanks for correcting my error. 😬

No worries, I just thought I’d mention it in case it did matter 🙂.

> [@spence](#):
>
> Yes the `insert_anchor_links` won’t work for pages unfortunately.

Do you know the reasoning behind that? It seems like a perfect setting for an individual page.

> [@spence](#):
>
> Specifically, it seems that based on what you’re asking you might be able to use the `render = false` setting with your `website` section’s front matter, i.e. `website/_index.md`.

Yes, while this feels a little clunky, it seems to solve my issue.

What I did was

1. rename `projects/website/index.md` to `projects/website.md` (and fix some internal links on other pages)
2. add `projects/website/_index.md` with the following content.

```auto
+++
title = "Placeholder to make this folder a section"
render = false
insert_anchor_links = "right"
+++

```

3. re-add `insert_anchor_links = "right"` to `projects/_index.md`

After that both `projects/website/index.html` and `projects/website/markdown.html` have anchor links added to the headers.

> [@spence](#):
>
> (btw you can also take this a step further and mark the website section as `transparent = true` and it will just inherit everything from the projects section, I think).

This doesn’t work, because it will also add the pages from the `projects/website/` subsection to the `projects/` section.

> [@spence](#):
>
> [pages vs sections] it’s not such a terrible way to do things

I am too new to Zola to decide on that. That said it can be confusing (different front matter, settings not being applied to orphaned pages, orphaned pages themselves, …) and results in issues like mine that require a “workaround”.

For example it now doesn’t make much sense, that I can’t have `website/index.md` and `website/_index.md` (with `render = false`), while `website.md` and `website/_index.md` are fine. 🤔.

Thank you for pushing me in the right direction.

---

<div class="post-metadata">

**Author:** ![balu](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/balu/32/1295_2.png) [@balu](https://zola.discourse.group/u/balu)\
**Post date:** [September 30, 2024, 3:43pm UTC](https://zola.discourse.group/t/why-are-anchor-links-not-available-to-pages/1752/9 "2024-09-30T15:43:11Z")

</div>

Just as a heads up:

While this works for me, it conflicts with Zola’s documentation on [asset colocation](https://www.getzola.org/documentation/content/overview/#asset-colocation). 🙂

> Pages with co-located assets should not be placed directly in their section directory (such as `latest-experiment.md`), but as an `index.md` file in a dedicated directory (`latest-experiment/index.md`), like so:

I am going to ignore this for now 😉
