Use anchor links inside table of contents #66
-
Hello! I am using both
and this 1) generates a table of contents at the top of my page and 2) adds anchor links to each section heading. However, I'd like my table of contents to use anchor links instead of full links. Here's my repository and the page on which I'm rendering table of contents is here. As you can see, I do have a perfect table of contents, but the links in the table of contents don't take me to the different parts of this page. Instead, they link to the full html page corresponding to each entry. Is there a way to do this? I am using jekyll's collections to build this page. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi! Glad to see you're using the sister projects together 😄 Alright, this is very likely happening because of the way that you are generating your headings. {% assign sorted_chapters = site.GPI_chapters | sort:"chapter" %}
{% for entry in sorted_chapters %}
<h3>
<a href="{{site.baseurl}}{{entry.url}}">
{{ entry.title }}
</a>
</h3>
<p>{{ entry.content | markdownify }}</p>
{% endfor %} The way that {% include toc.html html=content sanitize=true %} |
Beta Was this translation helpful? Give feedback.
-
Hi @allejo -- thanks for looking into this. Unfortunately, adding I'm happy to make some changes to the way I generate my |
Beta Was this translation helpful? Give feedback.
Hi @allejo -- thanks for looking into this. Unfortunately, adding
sanitize=true
seems to strip away the link from the t.o.c. completely. Now there is neither an anchor link nor a regular link. You can see this on my rendered page here.I'm happy to make some changes to the way I generate my
summaries.md
page (as long as I can use a for-loop) if it will help solve this problem.