MkDocs Custom Plugins Development

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1262
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1171
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    874
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1094
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    831
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    851

MkDocs Custom Plugin Development

MkDocs plugins are Python classes connected via build lifecycle events. They can modify page content, navigation, configuration, and final HTML output.

Plugin Structure

# my_mkdocs_plugin/__init__.py
from mkdocs.plugins import BasePlugin
from mkdocs.config import config_options
from mkdocs.config.base import Config

class MyPluginConfig(Config):
    api_url = config_options.Type(str, default='')
    cache_timeout = config_options.Type(int, default=3600)
    enabled = config_options.Type(bool, default=True)


class MyMkDocsPlugin(BasePlugin[MyPluginConfig]):

    def on_config(self, config):
        """Called after loading mkdocs.yml"""
        if not self.config.enabled:
            return config
        # Can modify global config
        config['extra']['my_plugin_version'] = '1.0.0'
        return config

    def on_page_markdown(self, markdown, page, config, files):
        """Modify Markdown before HTML conversion"""
        # Replace custom tags
        markdown = markdown.replace('{{VERSION}}', self._get_version())
        return markdown

    def on_page_content(self, html, page, config, files):
        """Modify rendered page HTML"""
        # Add custom banner to specific pages
        if page.meta.get('deprecated'):
            banner = '<div class="deprecated-notice">⚠️ Deprecated section</div>'
            html = banner + html
        return html

    def on_page_context(self, context, page, config, nav):
        """Add variables to template context"""
        context['api_status'] = self._get_api_status()
        return context

    def on_files(self, files, config):
        """Add/remove files from build"""
        return files

    def on_nav(self, nav, config, files):
        """Modify navigation"""
        return nav

    def on_post_build(self, config):
        """After build completion"""
        self._notify_build_complete()

    def _get_version(self):
        import requests
        resp = requests.get(f"{self.config.api_url}/version", timeout=5)
        return resp.json().get('version', 'unknown')

Registration via entry_points

# pyproject.toml
[project.entry-points."mkdocs.plugins"]
my-plugin = "my_mkdocs_plugin:MyMkDocsPlugin"
# mkdocs.yml
plugins:
  - my-plugin:
      api_url: https://api.myproject.com
      cache_timeout: 7200

Plugin for Generating API Pages

class ApiDocsPlugin(BasePlugin):
    """Generates documentation pages from OpenAPI spec"""

    def on_files(self, files, config):
        import yaml
        import requests
        from mkdocs.structure.files import File

        spec = requests.get(self.config.openapi_url).json()

        for path, methods in spec['paths'].items():
            for method, operation in methods.items():
                content = self._generate_endpoint_page(path, method, operation, spec)
                # Create virtual file without disk writing
                file = File.generated(
                    config,
                    f"api/{self._path_to_slug(path)}-{method}.md",
                    content=content,
                )
                files.append(file)

        return files

    def _generate_endpoint_page(self, path, method, operation, spec):
        return f"""# {operation.get('summary', path)}

**{method.upper()}** `{path}`

{operation.get('description', '')}

## Parameters

{self._render_parameters(operation.get('parameters', []))}

## Responses

{self._render_responses(operation.get('responses', {}))}
"""

Developing a plugin for generating pages from external sources takes 2–5 days.