diff --git a/src/dragonglass/template.py b/src/dragonglass/template.py index c84ae97..e822908 100644 --- a/src/dragonglass/template.py +++ b/src/dragonglass/template.py @@ -89,8 +89,8 @@ def template_vars(node: SourceNode, ctxt: Context) -> dict[str, Any]: tvars["dragonglass_version"] = __version__ tvars["python_version"] = f"{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}" - # Compute backlinks for this node. - backlinks = sorted(node.backlinks, key=lambda n: n.page_title) + # Compute backlinks for this node. Don't include nodes that aren't published. + backlinks = sorted([n for n in node.backlinks if n.publish], key=lambda n: n.page_title) tvars['backlinks'] = [{'title': n.page_title, 'link': n.link_target(ctxt.url_prefix, node if ctxt.relative_links else None)} for n in backlinks]