Skip to main content

Django Meta OG

HTML Meta tags OpenGraph for Django. The project uses the project DjangoCMS Meta OG project.

Install

pip install django-meta-og

Add into settings.py:

from django.utils.translation import gettext_lazy as _

INSTALLED_APPS = [
    "django_meta_og",
    ...
]

TEMPLATES  = [
    {"OPTIONS": {
            "context_processors": [
                "django_meta_og.context_processors.meta",
                ...
            ]
        }
    }
]

Add into the templates:

{% load django_meta_og %}
{% django_meta_og_prefix as og_prefix %}
<head{% if og_prefix %} prefix="{{ og_prefix }}"{% endif %}>
    {% include "django_meta_og/header_meta.html" %}

The result can be:

<head prefix="og: https://ogp.me/ns#">
    <meta property="og:type" content="website" />
    <meta property="og:title" content="The Title" />
    <meta property="og:url" content="https%3A%2F%2Fexample.com%2F" />
    ...
</head>

Prefix for Meta tags in template

Some Meta tags may already be defined in the template. Their prefix is ​​included in the prefix list via the definition in settings:

# Example of tag definition already used in the templates.
META_OG_PREFIX_IN_TEMLATES = (
    ("og", "https://ogp.me/ns#"),
    ("article", "https://ogp.me/ns/article#"),
)

Dynamic content

Special values ​​can be replaced with some content. A list of these values ​​is provided in the form in the item administration.

# Dynamic content - Key replacement for specific content.
PAGE_META_OG_DYNAMIC_CONTENT = {
    "ogc:page_url": (
        "django_meta_og.dynamic_content.get_page_url",
        _("Set the page absolute URL (together with parameters)."),
    ),
}

Admininstration

You can enter any Meta values. These are entered in three levels - Namespace, Property and Content.

Namespace

Namespace list

Namespace form

Property

Property list

Property form

Content

Content list

Content form

License

BSD License

Metadata

Release files for django-meta-og 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-meta-og 2.0.0
File Size Uploaded
django_meta_og-2.0.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-meta-og 2.0.0
File Interpreter ABI Platform
django_meta_og-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / django_meta_og-2.0.0.tar.gz

Download URL django_meta_og-2.0.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
80d73fddd26578967c4db5033af787aada52b5e77759225aee00d362ad9a784c
BLAKE2b-256 checksum
How to use checksums
1040ec4f2c0c25803269f685eb8d61d9fd8531b75aec06c4c35e8b01ae578135
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / django_meta_og-2.0.0-py3-none-any.whl

Download URL django_meta_og-2.0.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93a4645df91f3dbae26eb597845869f034132aa93c95c381100425f7cee9909c
BLAKE2b-256 checksum
How to use checksums
0e797d22d85f62ad28b6c9ccbc2a73f33b712bbd696f651ff804020fc4918eee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page