No TOC in Summary (without more comment marker)
tags: export-option toc summary endtoc
Description/Summary
By default, Hugo will dump everything at the beginning of a post into
its .Summary
(See Hugo content summaries). As TOC enabled using the
export option like toc:t
is inserted at the beginning of a post, TOC
will be shown in that summary too!
In this example, the special comment more
is not used. …
Content
By default, Hugo will dump everything at the beginning of a post into
its .Summary
(See Hugo content summaries). As TOC enabled using the
export option like toc:t
is inserted at the beginning of a post, TOC
will be shown in that summary too!
In this example, the special comment more
is not used.
ox-hugo
’s Solution
#
ox-hugo
helps prevent that with a workaround.. it inserts a special
HTML comment <!--endtoc-->
after the TOC.
Snippet #
As the more
comment is not present, the summary_minus_toc.html
partial used for this test site ensures that only the first 300 (or
so) characters after <!--endtoc-->
is considered as summary.
This partial needs to be used wherever the summary text is needed
(example: the Opengraph og:description
meta tag).
Page (Debug)
Page Variable | Value | |
---|---|---|
Name | "No TOC in Summary (without more comment marker)" | |
Title | "No TOC in Summary (without more comment marker)" | |
ResourceType | "page" | |
Kind | "page" | |
Section | "posts" | |
Draft | false | |
Type | "posts" | |
Layout | "" | |
Permalink | "https://ox-hugo.scripter.co/test/posts/no-toc-in-summary-without-more/" | |
RelPermalink | "/posts/no-toc-in-summary-without-more/" | |
Data |
| |
NextPage | No TOC in Summary (with more comment marker) | |
PrevPage | Number 0 levels | |
NextInSection | No TOC in Summary (with more comment marker) | |
PrevInSection | Number 0 levels |
Page Params (Debug)
Key | Type | Value |
---|---|---|
draft | bool | false |
iscjklanguage | bool | false |
lastmod | time.Time | 2022-01-16 11:59:06 -0500 -0500 |
tags | []string | "export-option" "toc" "summary" "endtoc" |
title | string | "No TOC in Summary (without more comment marker)" |
File Object (Debug)
FileInfo Variable | Value |
---|---|
UniqueID | "6594a46272d8639a10f77f8f27e4b986" |
BaseFileName | "no-toc-in-summary-without-more" |
TranslationBaseName | "no-toc-in-summary-without-more" |
Lang | "en" |
Section | "posts" |
LogicalName | "no-toc-in-summary-without-more.md" |
Dir | "posts/" |
Ext | "md" |
Path | "posts/no-toc-in-summary-without-more.md" |