Skip to content

Unexpected behaviour with page.is_homepage #1919

@StarfallProjects

Description

@StarfallProjects

Starting a new site and rolling my own theme. Came across some slightly odd behaviour.

Mkdocs version 1.0.4
Python version 3.7.1

Expected:
page.is_homepage evaluates to True on the home (index.md) of the site, and false on all other pages.

Actual:
page.is_homepage evaluates to True on the home (index.md), and on any other index.md that is included in the nav object without nesting.

Examples:

The unexpected result:

nav:
  - Home: index.md  <--- page.is_homepage evaluates to True
  - About: about.md <--- page.is_homepage evaluates to False
  - Projects: projects/index.md <--- page.is_homepage evaluates to True

Changing the filename causes it to evaluate to false:

nav:
  - Home: index.md  <--- page.is_homepage evaluates to True
  - About: about.md <--- page.is_homepage evaluates to False
  - Projects: projects/test.md <--- page.is_homepage evaluates to False

If I tweak it a bit, so that the sections are nested, then it evaluates to false as I'd expect:

nav:
  - About: 
      - About: about.md <--- page.is_homepage evaluates to False
  - Projects: 
       - Project home: projects/index.md <--- page.is_homepage evaluates to False

This feels like a bug - especially as simply changing the markdown file name causes the behaviour to change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions