Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

django-kp-html-meta

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-kp-html-meta

kp_html_meta is a Django app to generate html meta tags for improve SEO.

  • 0.1
  • PyPI
  • Socket score

Maintainers
1

================= kp_html_meta

kp_html_meta is a Django app to generate html meta tags for improve SEO.

Quick start

  1. Install django-kp-html-meta::

    pip install django-kp-html-meta

  2. Add "kp_static_version" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [ ... 'kp_html_meta', ]

  3. Define default values in you settings.py (optional)::

    Default values

    KP_META = { 'kp_meta_title': "Test title", # ex: Test title 'kp_meta_description': "Test description", # ex: 'kp_meta_keywords': "Test keyword", 'kp_meta_graph_type': "article ", 'kp_meta_graph_image': "https://mywebsite.com/logo.jpg", 'kp_meta_graph_url': "https://mywebsite.com", 'kp_meta_graph_locale': "en", 'kp_get_base_url': "https://mywebsite.com", 'kp_meta_graph_site_name': "mywebsite", }

  4. Load templatetags into your template::

    {% load kp_meta %}

    {% kp_meta %}
  5. Result::

    Test title

Customization

The values defined in the settings.py file are default values. They are used if no other values exist. You can customize the content of the HTML tags according to your templates. Example::

from django.db import models
from kp_html_meta.models import KPMetaHelper

class DummyModel(models.Model, KPMetaHelper):
    # ... some fields

def get_kp_meta_title(self):
    # kp_meta_title in settings.py
    return self.title

def get_kp_meta_description(self):
    # kp_meta_description in settings.py
    return self.text_of_my_article[:200]

def get_kp_meta_keywords(self):
    # If None then the value defined in settings.py will be used.
    # kp_meta_keywords in settings.py
    return None

def get_kp_meta_graph_type(self):
    return None

def get_kp_meta_graph_image(self):
    return None

def get_kp_meta_graph_url(self):
    return None

def get_kp_meta_graph_locale(self):
    return None

def get_kp_meta_graph_site_name(self):
    """
    Return site name

    for example:

    return "mywebsite.tld"

    or

    from django.conf import settings
    kp_settings = getattr(settings, 'KP_META')
    :return kp_settings['kp_meta_graph_site_name']

    or

    from django.contrib.sites.models import Site
    current_site = Site.objects.get_current()
    return current_site.domain

    """

    return None

def get_kp_get_base_url(self):
    """
    Return base url

    for example:

    return "https://mywebsite.tld"

    or

    from django.conf import settings
    kp_settings = getattr(settings, 'KP_META')
    :return kp_settings['kp_get_base_url']

    or

    from django.contrib.sites.models import Site
    current_site = Site.objects.get_current()
    return "https://%s" % current_site.domain

    """
    return None

You can extend your templates with predefined fields::

from kp_html_meta.models import KPMetaGraphFiler

# if you use django-filer
class DummyModel(KPMetaGraphFiler):

from kp_html_meta.models import KPMetaGraphFileBrowser

# if you use django-filebrowser
class DummyModel(KPMetaGraphFileBrowser):

If you customize your models, use the templatetags like this::

{% load kp_meta %}
<head>
    <meta charset="UTF-8">
    {% kp_meta myobj %}
</head>

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc