Skip to main content

An MkDocs plugin that provides Ultralytics Docs customizations at https://docs.ultralytics.com.

Project description

MkDocs Ultralytics Plugin

The MkDocs Ultralytics Plugin is an easy-to-use plugin that generates meta description, image, and share buttons based on your Markdown content. It's specifically designed for MkDocs and provides a seamless integration to enhance your documentation.

Features

  • Generate meta description tag based on the first paragraph of a page
  • Generate Open Graph (Facebook) and Twitter meta tags with image and description
  • Add share buttons for Twitter and LinkedIn

Installation

To install the MkDocs Ultralytics Plugin from pip, run the following command:

pip install mkdocs-ultralytics-plugin

Usage

To enable the plugin in your MkDocs project, add it to the plugins section of your mkdocs.yml file:

plugins:
  - mkdocstrings
  - search
  - ultralytics

Plugin Arguments

The plugin supports the following arguments:

  • verbose: Enable or disable verbose output (default: True)
  • enabled: Enable or disable the plugin (default: True)
  • default_image: Set a default image URL if no image is found in the content (default: None)
  • add_desc: Enable or disable the generation of meta description tags (default: True)
  • add_image: Enable or disable the generation of meta image tags (default: True)
  • add_share_buttons: Enable or disable the addition of share buttons for Twitter and LinkedIn (default: True)

To use the arguments, add them to the ultralytics plugin section in your mkdocs.yml file:

plugins:
  - mkdocstrings
  - search
  - ultralytics:
      verbose: True
      enabled: True
      default_image: "https://example.com/default-image.png"
      add_desc: True
      add_image: True
      add_share_buttons: True

How it works

The plugin works by extracting the first paragraph and the first image (if available) from your Markdown content. It then generates and adds the appropriate meta description, image tags, and share buttons to the page.

Meta Description

The meta description is extracted from the first paragraph of your Markdown content. The generated description is then added to the page's <head> section as a <meta name="description"> tag.

Meta Image

The meta image is extracted from the first image (if available) in your Markdown content. The generated image URL is then added to the page's <head> section as a <meta property="og:image"> and <meta property="twitter:image"> tags.

Share Buttons

If the add_share_buttons argument is enabled, share buttons for Twitter and LinkedIn are added to the page, allowing users to easily share the content on social media platforms.

Plugin Code

The core functionality of the plugin is implemented in plugin.py, which defines the MetaPlugin class:

from bs4 import BeautifulSoup
from mkdocs.plugins import BasePlugin

class MetaPlugin(BasePlugin):

    def on_page_content(self, content, page, config, files):
        # ... (code to generate meta description and image)

    def on_post_page(self, output, page, config):
        # ... (code to update the output with the generated meta tags)

License

This project is licensed under the AGPL-3.0 License. For more information, see the LICENSE file.

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-ultralytics-plugin-0.0.20.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

mkdocs_ultralytics_plugin-0.0.20-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-ultralytics-plugin-0.0.20.tar.gz.

File metadata

File hashes

Hashes for mkdocs-ultralytics-plugin-0.0.20.tar.gz
Algorithm Hash digest
SHA256 7b668dd799decf2120601c28b597d241d051450bacb26389ab1ee01c6fea3b25
MD5 c85efc2dd9a340e3b935a9fe176c6533
BLAKE2b-256 54f7fe476989a9c95dbdbaa026cce3813f8097b0b529007833be22369c978140

See more details on using hashes here.

File details

Details for the file mkdocs_ultralytics_plugin-0.0.20-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_ultralytics_plugin-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 1e9f48c51af257286553ff084f9ab1eca27b553b5cf6b5b294d3ce7ba93025ab
MD5 f4d3170c613fa8afe8a5c28c54565e75
BLAKE2b-256 1c0f488696c0a48760e721ab6d3b28e51ba74ffba8b112447ee2b54a81418f73

See more details on using hashes here.

Supported by

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