@@ -143,9 +143,12 @@ def __init__(self, post: Post, config: MkDocsConfig, files: Files):
143
143
self .file = copy (post .file )
144
144
self .post = post
145
145
146
- # Initialize configuration, contents and metadata
146
+ # Set canonical URL, or we can't print excerpts when debugging the
147
+ # blog plugin, as the `abs_url` property would be missing
148
+ self ._set_canonical_url (config .site_url )
149
+
150
+ # Initialize configuration and metadata
147
151
self .config = post .config
148
- self .markdown = post .markdown
149
152
self .meta = post .meta
150
153
151
154
# Initialize authors and categories - note that views usually contain
@@ -189,6 +192,12 @@ def render(self, page: Page, separator: str):
189
192
processor : ExcerptTreeprocessor = self .md .treeprocessors [at ]
190
193
processor .base = page
191
194
195
+ # Ensure that the excerpt includes a title in its content, since the
196
+ # title is linked to the post when rendering - see https://t.ly/5Gg2F
197
+ self .markdown = self .post .markdown
198
+ if not self .post ._title_from_render :
199
+ self .markdown = "\n \n " .join ([f"# { self .post .title } " , self .markdown ])
200
+
192
201
# Convert Markdown to HTML and extract excerpt
193
202
self .content = self .md .convert (self .markdown )
194
203
self .content , * _ = self .content .split (separator , 1 )
0 commit comments