-
Public Repo https://github.com/robw4/test-site Description I am trying to add a table of contents to a layout in
But instead of rendering as a list of hyperlinks it renders as a block of text instead as shown below. I am a jekyll novice so apologies if the answer is obvious but any help would be most appreciated. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Make sure that your Here are the important changes that break toc.html in your test repo. diff --git a/_includes/toc.html b/_includes/toc.html
index 6f19b31..22406be 100644
--- a/_includes/toc.html
+++ b/_includes/toc.html
@@ -130,23 +130,23 @@
{% assign submenuIndentation = space | prepend: ' ' %}
{% capture my_toc %}{{ my_toc }}
- {{ submenuIndentation }}{:.{{ include.submenu_class | replace: '%level%', previousLevel }}}{% endcapture %}
+{{ submenuIndentation }}{:.{{ include.submenu_class | replace: '%level%', previousLevel }}}{% endcapture %}
{% endif %}
{% capture my_toc %}{{ my_toc }}
- {{ space }}{{ listModifier }} {{ listItemClass }} {{ list_item }}{% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
+{{ space }}{{ listModifier }} {{ listItemClass }} {{ list_item }}{% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
{% assign previousLevel = indentAmount %}
{% endfor %}
{% if include.class and include.class != blank %}
{% capture my_toc %}{:.{{ include.class }}}
- {{ my_toc | lstrip }}{% endcapture %}
+{{ my_toc | lstrip }}{% endcapture %}
{% endif %}
{% if include.id %}
{% capture my_toc %}{: #{{ include.id }}}
- {{ my_toc | lstrip }}{% endcapture %}
+{{ my_toc | lstrip }}{% endcapture %}
{% endif %}
<!--
@@ -164,7 +164,7 @@
{% endfor %}
{% capture my_toc %}{{ my_toc }}
- {{ closingSpace }}{:.{{ include.submenu_class | replace: '%level%', lvl }}}{% endcapture %}
+{{ closingSpace }}{:.{{ include.submenu_class | replace: '%level%', lvl }}}{% endcapture %}
{% endfor %}
{% endif %}
{% endcapture %}{% assign tocWorkspace = '' %}{{ my_toc | markdownify | strip }}
\ No newline at end of file
|
Beta Was this translation helpful? Give feedback.
-
Thanks! I realise my editor was reformatting whitespace when I opened the file. This has fixed the issue. Thanks a lot 👍 |
Beta Was this translation helpful? Give feedback.
Make sure that your
includes/toc.html
is formatted exactly as thetoc.html
in this repository. Some indentation may seem weird in this repo, but if you notice the weird indentation happens inside of{% capture %}
statements. The extra space that's been added in your copy of this file is what's causing it to be rendered as a code block instead.Here are the important changes that break toc.html in your test repo.