Skip to content

Nested dot folders copied upon build #1981

@squidfunk

Description

@squidfunk

Sometimes it's necessary to include files in a theme which MkDocs should conditionally include in the templates, but not copy to the site directory when the documentation is built. As discussed in #1980, MkDocs will ignore files that start with a ., but this only applies to top-level directories. It would be great if MkDocs could exclude nested dot directories from the build.

A concrete example: the next version of the Material theme will bundle the FontAwesome files as SVGs for inlining during build time, but MkDocs copies all of them to the site directory. The folder structure is:

assets/images/icons/fontawesome/...

The current workaround is to add a *.html to the files bundles with the theme, resulting in a *.svg.html extension for each of the 1.500 icons. While this works, it's semantically incorrect.

If MkDocs would ignore nested dot directories, we could just use:

assets/images/icons/.fontawesome/...

As pointed out by @waylan, the code in question is here:

patterns = ['.*', '*.py', '*.pyc', '*.html', '*readme*', 'mkdocs_theme.yml']
patterns.extend('*{}'.format(x) for x in utils.markdown_extensions)
patterns.extend(config['theme'].static_templates)

I'm not proficient in Python, but since this looks like a glob implementation, I would guess that **/.* would solve the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions