Skip to main content

A mkdocs plugin that excludes assets that are unused (orphaned) from being included in the final mkdocs output.

Project description

MkDocs Exclude Unused (orphaned) Files

A simple plugin for excluding files from being included in the mkdocs output if they are not referenced on other pages.

Installation

pypi current version

Run pip install --upgrade mkdocs-exclude-unused-files

Configuration

Basic Configuration in the mkdocs.yml file:

plugins:
  - exclude-unused-files:
      file_types_to_check: ["png", "jpg", "jpeg", "gif"]
      enabled: !ENV [CI, false]

This configuration will exclude all files from the final mkdocs output that has one of the configured file endings and are not referenced/linked to other pages.

Default types

The plugin uses a default set of file types:

png, jpg, jpeg, gif, pdf, ico, drawio, tif, tiff, zip, tar.gz, rar, ogg, mp3, mp4, vtt , ogv, mov, svg, pot, potx, ppsx, ppt, pptx, xlt, xltx, xls, xlsx, doc, docx, dot, dotx, vst, vstx, vsd, vsdx

All Configuration Options

Setting Default Description
enabled True Whether the plugin is enabled when building your project. If you want to switch the plugin off, e.g. for local builds, use an environment variables.
enabled_on_serve False Whether the plugin is enabled when serving your project. It does not apply if enabled is False. It's just to explicitly enable the plugin during mkdocs serve.
dry_run False Only print output into the command line and don't actually delete anything
silent False Don't print out the found orphan files in the build process
force_delete False By default the plugin only deletes files that are actually in the configured mkdocs output directory (site_dir). If you want to delete these files anyways due to your setup, enable this flag
file_types_to_check [] Only check these file types for their usage and delete them if necessary.
file_types_override_mode replace Behavior of file_types_to_check towards default types: replace - uses only defined types, append - adds additional types to default list, remove - removes specified types from default.
file_names_to_never_remove ["favicon"] Files with these names will never get deleted, even if no usage is detected.
folders_to_never_remove_from ["assets"] Files in these folders will never get deleted, even if no usage is detected. Useful for always including specific static files.
file_name_suffixes_to_trim ["#only-light", "#only-dark"] Trim-away suffixes in this list when checking if a file-name is used. This is used for ignoring material-mkdoc's color-palette-toggle instructions (see Issue-4).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_exclude_unused_files-1.4.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_exclude_unused_files-1.4.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_exclude_unused_files-1.4.1.tar.gz.

File metadata

  • Download URL: mkdocs_exclude_unused_files-1.4.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1015-azure

File hashes

Hashes for mkdocs_exclude_unused_files-1.4.1.tar.gz
Algorithm Hash digest
SHA256 96864e19a518afbb7f6e8bf4cf724f880da483e108d1dc00b58ca04a7214282d
MD5 28f2523c982216646df1a6e615936b84
BLAKE2b-256 cdb348d7fc03b8d9f5d84507f56a30e9f9930dee87433456db6c394baa757a88

See more details on using hashes here.

File details

Details for the file mkdocs_exclude_unused_files-1.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_exclude_unused_files-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 da702f03d19e696fedb7f42505cf52a858e4c917478ad2475fee4f01350bda16
MD5 199a0b17b2edf4bc08d9550d8a45b800
BLAKE2b-256 39dec8423890b484d6e2203240389bf1ba2af9d18272470cf2c357506d1190b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page