Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme-option to specify theme-specific assets to not be copied #1980

Closed
squidfunk opened this issue Feb 10, 2020 · 6 comments
Closed

Theme-option to specify theme-specific assets to not be copied #1980

squidfunk opened this issue Feb 10, 2020 · 6 comments
Labels

Comments

@squidfunk
Copy link

@squidfunk squidfunk commented Feb 10, 2020

For the latest Material theme, I'm switching to an SVG-based approach for FontAwesome which will reduce the payload by a huge margin, i.e. the SVGs are directly included from the Jinja templates, and thus must be distributed with the theme:

<a href="{{ social.link }}" target="_blank" rel="noopener" class="md-footer-social__link">
  {% include "assets/images/icons/fontawesome/" ~ social.icon ~ ".svg" %}
</a>

The problem is, that on build, MkDocs will copy over all SVG files that are part of the theme, thus the build takes quite long and there're a lot of unnecessary file that should not be part of the build.

I've skimmed through the docs but didn't find an option to say: please don't include files under this directory. Ideally, as a theme author, I would like to specify which theme files are only necessary during build time and need not be distributed.

@squidfunk

This comment has been minimized.

Copy link
Author

@squidfunk squidfunk commented Feb 10, 2020

... what solves the issue at least symptomatically is if I rename all *.svg . files to *.svg.html – MkDocs will not copy the files anymore into the site directory – but that's a rather less ideal solution.

@waylan

This comment has been minimized.

Copy link
Member

@waylan waylan commented Feb 10, 2020

Any file or directory which starts with a dot (.) is ignored by MkDocs. So long as the content is included by Jinja, that should work fine for you.

It appears that this behavior is not documented. We probably should do that. For the record, the ignored files (for a theme) are defined 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)

@squidfunk

This comment has been minimized.

Copy link
Author

@squidfunk squidfunk commented Feb 10, 2020

I didn't know about that, but it's perfect! Super elegant solution!

@squidfunk squidfunk closed this Feb 10, 2020
@squidfunk

This comment has been minimized.

Copy link
Author

@squidfunk squidfunk commented Feb 10, 2020

... uh, but could it be that this only applies to files on the root level of the theme?

@waylan

This comment has been minimized.

Copy link
Member

@waylan waylan commented Feb 10, 2020

... uh, but could it be that this only applies to files on the root level of the theme?

If it does, then that is a bug.

@squidfunk

This comment has been minimized.

Copy link
Author

@squidfunk squidfunk commented Feb 10, 2020

Just tested it – it only works for the top-level. I'm opening a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.