Skip to main content

Django HTML Meta tags for OpenGraph.

Project description

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

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

django_meta_og-2.0.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

django_meta_og-2.0.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file django_meta_og-2.0.0.tar.gz.

File metadata

  • Download URL: django_meta_og-2.0.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for django_meta_og-2.0.0.tar.gz
Algorithm Hash digest
SHA256 80d73fddd26578967c4db5033af787aada52b5e77759225aee00d362ad9a784c
MD5 f6faacfb2081226638a5cb9b8099b511
BLAKE2b-256 1040ec4f2c0c25803269f685eb8d61d9fd8531b75aec06c4c35e8b01ae578135

See more details on using hashes here.

File details

Details for the file django_meta_og-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_meta_og-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for django_meta_og-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93a4645df91f3dbae26eb597845869f034132aa93c95c381100425f7cee9909c
MD5 f396325180a8c8b7f84b77c946aa55d0
BLAKE2b-256 0e797d22d85f62ad28b6c9ccbc2a73f33b712bbd696f651ff804020fc4918eee

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