Replacing some features of Yoast or SEMrush for django CMS users.
In other words, django-check-seo will tell you if you have problems concerning a broad range of SEO aspects of your pages.
The following instructions are for an installation on a djangocms-based website using python >= 3 & django >= 2, or for a djangocms-based website using python >= 2.7 & django >= 1.8.15.
- Install module using pipenv:
pipenv install django-check-seo
- Or pip:
pip install django-check-seo
- Add it to your installed apps:
"django_check_seo",
- Add it to your
urls.py
(beforeurl(r'^', include('cms.urls')),
or it will not work):
url(r"^django-check-seo/", include("django_check_seo.urls")),
- Or add this if you're using path:
path("django-check-seo/", include("django_check_seo.urls")),
-
Update your site parameters with correct url (example for dev environment)
-
(optional) Configure the settings, and/or force http instead of https, and/or add authentification (see config).
This application need beautifulsoup4
(>=4.7.0), requests
, djangocms
& djangocms_page_meta
(==0.8.5 if using django < 1.11).
Basic config (used by default) is in django-check-seo/conf/settings.py
:
DJANGO_CHECK_SEO_SETTINGS = {
"content_words_number": [300, 600],
"internal_links": 1,
"external_links": 1,
"meta_title_length": [30, 60],
"meta_description_length": [50, 160],
"keywords_in_first_words": 50,
"max_link_depth": 3,
"max_url_length": 70,
}
If you need to change something, just define a dict named DJANGO_CHECK_SEO_SETTINGS
in your settings.py.
If you put this in your settings.py
file:
DJANGO_CHECK_SEO_SETTINGS = {
"internal_links": 25,
"meta_title_length": [15,30],
}
Then this will be the settings used by the application:
DJANGO_CHECK_SEO_SETTINGS = {
"content_words_number": [300, 600],
"internal_links": 25,
"external_links": 1,
"meta_title_length": [15,30],
"meta_description_length": [50, 160],
"keywords_in_first_words": 50,
"max_link_depth": 3,
"max_url_length": 70,
}
Want to know more ? See the wiki page Settings explained.
Since django-check-seo will count things like number of words on the main content and the number of internal links, it is important to only select the main content of the page (an address in the footer is not the main content of your page).
Django-check-seo use a string (named DJANGO_CHECK_SEO_EXCLUDE_CONTENT
) of css selectors to exclude unwanted html nodes from the html content:
DJANGO_CHECK_SEO_EXCLUDE_CONTENT = "tag, .class, #id, tag > .child_class"
You can find a reference table of css selectors explained here (on mdn docs).
See this issue comment for an example.
By default, the application will attempt to make requests in https.
To enable plain http queries, you can add a variable named DJANGO_CHECK_SEO_FORCE_HTTP
set to True
in your settings.py.
# Force HTTP
DJANGO_CHECK_SEO_FORCE_HTTP = True
# Force HTTPS (default case, same as not defining the variable)
DJANGO_CHECK_SEO_FORCE_HTTP = False
The website you want to test may require a prior connection due to a .htaccess file (or may use wsgi-basic-auth), which prevents django-check-seo from accessing its html code.
To prevent this, you can specify the login informations (username/password) in the DJANGO_CHECK_SEO_AUTH
dictionnary (in your website settings).
This dictionary must contain two keys named user
and pass
.
- In
mywebsite/settings.py
:
DJANGO_CHECK_SEO_AUTH = {
"user": os.getenv("HTACCESS_USER"),
"pass": os.getenv("HTACCESS_PASS"),
}
- In
.env
file:
export HTACCESS_USER=myusername
export HTACCESS_PASS=mypassword
WSGI_AUTH_CREDENTIALS=$HTACCESS_USER:$HTACCESS_PASS
When you really want django-check-seo to follow a redirection and you really want to authenticate on the redirected site using the DJANGO_CHECK_SEO_AUTH
credentials, you can set this config var to True
in your site settings:
DJANGO_CHECK_SEO_AUTH_FOLLOW_REDIRECTS = True
Warning! This could be considered a bad practice to allow this by default, because if you create a redirection on your (authenticated-only accessible) website, then the destination website will have access to the credentials by reading the Authorization
header (see CVE-2014-1829). See this issue for a valid usecase.
Other screenshots and videos are available on the wiki.
They are located in tests
folder.
The file launch_tests.sh
is here to manage tests launching for you. You only need python3-venv
(for python3 venv) and virtualenv
(for python2 venv) in order to make it work (example video).
See CONTRIBUTING.md.
Take a look at the wiki: