landscape-bot: [![Code Health](https://landscape.io/badge/159489/landscape.svg?style=flat)](https://landscape.io/diff/146595)
Repository health decreased by 0.24% when pulling **[f42c054](https://github.com/d0ugal/mkdocs/commit/f42c054a9b0fc86f7ed40de43fec8ebb53ab4191) on d0ugal:auto-pages** into **[7cc4764](https://github.com/mkdocs/mkdocs/commit/7cc47645d357fa96bf7197e30b519f331e77a3d5) on mkdocs:master**.

 * [1 new problem was found](https://landscape.io/diff/146595) (including 0 errors and 1 code smell).
 * No problems were fixed.
landscape-bot: [![Code Health](https://landscape.io/badge/159492/landscape.svg?style=flat)](https://landscape.io/diff/146599)
Code quality remained the same when pulling **[7fc3de2](https://github.com/d0ugal/mkdocs/commit/7fc3de2959a6c94556be4f0e9c5a0cf27d451318) on d0ugal:auto-pages** into **[7cc4764](https://github.com/mkdocs/mkdocs/commit/7cc47645d357fa96bf7197e30b519f331e77a3d5) on mkdocs:master**.
landscape-bot: [![Code Health](https://landscape.io/badge/159492/landscape.svg?style=flat)](https://landscape.io/diff/146599)
Code quality remained the same when pulling **[7fc3de2](https://github.com/d0ugal/mkdocs/commit/7fc3de2959a6c94556be4f0e9c5a0cf27d451318) on d0ugal:auto-pages** into **[7cc4764](https://github.com/mkdocs/mkdocs/commit/7cc47645d357fa96bf7197e30b519f331e77a3d5) on mkdocs:master**.
landscape-bot: [![Code Health](https://landscape.io/badge/159508/landscape.svg?style=flat)](https://landscape.io/diff/146619)
Code quality remained the same when pulling **[d49f3a0](https://github.com/d0ugal/mkdocs/commit/d49f3a09fb5431351d5bd975e71f40a3cd69cdd4) on d0ugal:auto-pages** into **[7cc4764](https://github.com/mkdocs/mkdocs/commit/7cc47645d357fa96bf7197e30b519f331e77a3d5) on mkdocs:master**.
diff --git a/mkdocs.yml b/mkdocs.yml
index ad7ce968..930ccd95 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -4,19 +4,6 @@ site_description: Project documentation with Markdown.
 
 repo_url: https://github.com/mkdocs/mkdocs/
 
-pages:
-- Home: index.md
-- User Guide:
-    - Writing Your Docs: user-guide/writing-your-docs.md
-    - Styling Your Docs: user-guide/styling-your-docs.md
-    - Configuration: user-guide/configuration.md
-- About:
-    - License: about/license.md
-    - Release Notes: about/release-notes.md
-    - Contributing: about/contributing.md
-
-use_new_pages_structure: true
-
 markdown_extensions:
     toc:
         permalink: ""
diff --git a/mkdocs/config.py b/mkdocs/config.py
index 408e3393..71451244 100644
--- a/mkdocs/config.py
+++ b/mkdocs/config.py
@@ -145,6 +145,8 @@ def validate_config(user_config):
             elif utils.is_template_file(filename):
                 extra_templates.append(filename)
 
+    pages = utils.nest_paths(pages)
+
     if config['pages'] is None:
         config['pages'] = pages
     else:
diff --git a/mkdocs/nav.py b/mkdocs/nav.py
index 58b5bc14..d70628d3 100644
--- a/mkdocs/nav.py
+++ b/mkdocs/nav.py
@@ -22,13 +22,7 @@ def filename_to_title(filename):
     if utils.is_homepage(filename):
         return 'Home'
 
-    title = os.path.splitext(filename)[0]
-    title = title.replace('-', ' ').replace('_', ' ')
-    # Capitalize if the filename was all lowercase, otherwise leave it as-is.
-    if title.lower() == title:
-        title = title.capitalize()
-
-    return title
+    return utils.filename_to_title(filename)
 
 
 class SiteNavigation(object):
diff --git a/mkdocs/utils.py b/mkdocs/utils.py
index 971ce480..685e90aa 100644
--- a/mkdocs/utils.py
+++ b/mkdocs/utils.py
@@ -307,3 +307,60 @@ def get_theme_names():
     """Return a list containing all the names of all the builtin themes."""
 
     return os.listdir(os.path.join(os.path.dirname(__file__), 'themes'))
+
+
+def filename_to_title(filename):
+
+    title = os.path.splitext(filename)[0]
+    title = title.replace('-', ' ').replace('_', ' ')
+    # Capitalize if the filename was all lowercase, otherwise leave it as-is.
+    if title.lower() == title:
+        title = title.capitalize()
+
+    return title
+
+
+def find_or_create_node(branch, key):
+    """
+    Given a list, look for dictionary with a key matching key and return it's
+    value. If it doesn't exist, create it with the value of an empty list and
+    return that.
+    """
+
+    for node in branch:
+        if not isinstance(node, dict):
+            continue
+
+        if key in node:
+            return node[key]
+
+    new_branch = []
+    node = {key: new_branch}
+    branch.append(node)
+    return new_branch
+
+
+def nest_paths(paths):
+    """
+    Given a list of paths, convert them into a nested structure that will match
+    the pages config.
+    """
+    nested = []
+
+    for path in paths:
+
+        if os.path.sep not in path:
+            nested.append(path)
+            continue
+
+        directory, _ = os.path.split(path)
+        parts = directory.split(os.path.sep)
+
+        branch = nested
+        for part in parts:
+            part = filename_to_title(part)
+            branch = find_or_create_node(branch, part)
+
+        branch.append(path)
+
+    return nested

Regression with automatic pages config
Caused by: 7849e71b8401608f86e81b48e7b29d18e8408663
diff --git a/mkdocs/tests/utils_tests.py b/mkdocs/tests/utils_tests.py
index e2854187..41d066e6 100644
--- a/mkdocs/tests/utils_tests.py
+++ b/mkdocs/tests/utils_tests.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # coding: utf-8
 
+import os
 import unittest
 
 from mkdocs import nav, utils
@@ -108,3 +109,32 @@ class UtilsTests(unittest.TestCase):
             sorted(['flatly', 'cerulean', 'slate', 'bootstrap', 'yeti',
                     'spacelab', 'united', 'readable', 'simplex', 'mkdocs',
                     'cosmo', 'journal', 'cyborg', 'readthedocs', 'amelia']))
+
+    def test_nest_paths(self):
+
+        j = os.path.join
+
+        result = utils.nest_paths([
+            'index.md',
+            j('user-guide', 'configuration.md'),
+            j('user-guide', 'styling-your-docs.md'),
+            j('user-guide', 'writing-your-docs.md'),
+            j('about', 'contributing.md'),
+            j('about', 'license.md'),
+            j('about', 'release-notes.md'),
+        ])
+
+        self.assertEqual(
+            result,
+            [
+                'index.md',
+                {'User guide': [
+                    j('user-guide', 'configuration.md'),
+                    j('user-guide', 'styling-your-docs.md'),
+                    j('user-guide', 'writing-your-docs.md')]},
+                {'About': [
+                    j('about', 'contributing.md'),
+                    j('about', 'license.md'),
+                    j('about', 'release-notes.md')]}
+            ]
+        )

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.7
requirements/project.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
click==8.1.8
exceptiongroup==1.2.2
ghp-import==2.1.0
importlib-metadata==6.7.0
iniconfig==2.0.0
Jinja2==3.1.6
livereload==2.7.1
Markdown==3.4.4
MarkupSafe==2.1.5
-e git+https://github.com/mkdocs/mkdocs.git@7cc47645d357fa96bf7197e30b519f331e77a3d5#egg=mkdocs
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
python-dateutil==2.9.0.post0
PyYAML==6.0.1
six==1.17.0
tomli==2.0.1
tornado==6.2
typing_extensions==4.7.1
zipp==3.15.0

name: mkdocs
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - click==8.1.8
      - exceptiongroup==1.2.2
      - ghp-import==2.1.0
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - jinja2==3.1.6
      - livereload==2.7.1
      - markdown==3.4.4
      - markupsafe==2.1.5
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.1
      - six==1.17.0
      - tomli==2.0.1
      - tornado==6.2
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/mkdocs

mkdocs/tests/utils_tests.py::UtilsTests::test_nest_paths
mkdocs/tests/utils_tests.py::UtilsTests::test_create_media_urls
mkdocs/tests/utils_tests.py::UtilsTests::test_get_themes mkdocs/tests/utils_tests.py::UtilsTests::test_html_path mkdocs/tests/utils_tests.py::UtilsTests::test_is_html_file mkdocs/tests/utils_tests.py::UtilsTests::test_is_markdown_file mkdocs/tests/utils_tests.py::UtilsTests::test_reduce_list mkdocs/tests/utils_tests.py::UtilsTests::test_url_path mkdocs/tests/utils_tests.py::UtilsTests::test_yaml_load
mkdocs/config.py mkdocs/utils.py mkdocs.yml mkdocs/nav.py
mkdocs/config.py mkdocs/utils.py mkdocs.yml mkdocs/nav.py