diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index ed14627db..ba8a15a93 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -238,16 +238,17 @@ def generate_header_nav_html(n_links_before_dropdown=5): # Find the root document because it lists our top-level toctree pages root = app.env.tocs[app.config.root_doc] + # Iterate through each toctree node in the root document # Grab the toctree pages and find the relative link + title. links_html = [] # Can just use "findall" once docutils min version >=0.18.1 meth = "findall" if hasattr(root, "findall") else "traverse" for toc in getattr(root, meth)(toctree_node): - for _, page in toc.attributes["entries"]: + for title, page in toc.attributes["entries"]: # If this is the active ancestor page, add a class so we highlight it current = " current active" if page == active_header_page else "" - title = app.env.titles[page].astext() + title = title if title else app.env.titles[page].astext() links_html.append( f"""