This Enonic XP application adds a multitude of helpful meta fields for your Enonic XP site. Like Open Graph meta fields, Twitter Cards meta fields, Google Search Console meta tag, and more! It also let's you better customize your site's and contents' title tag and meta description information. By applying mixin-fields to each content you can easily fine tune your sites' SEO and social sharing!
This app will add the following functionality to your site:
- SEO friendly titles
- SEO meta description
- New in 1.5: Social media sharing image (custom per content)
- Open Graph meta data
- Twitter Cards meta data
- Google Search Console meta tag
- Canonical meta tag
- Robots.txt exclude setting
- New in 1.6: Widget for Content Studio that displays all the SEO data!
- New in 1.7: Configure the app through config-files on the server.
Go into the Enonic XP Application admin tool and install the app from the Enonic Market.
The SEO Meta Fields app will then be available to add to your websites through the Content Studio admin tool in Enonic XP. Edit your site content to add this app. Remember to save (after you've configured the app).
After adding this app you should see a new SEO
-section on your site and on all of your contents. The fields in this section can be used to set a custom title, description and/or image on each content, used only for SEO purposes. Starting with 6.15, click the "+ SEO" (or anywhere on the box) to add the SEO fields to any content when editing it. With the fields added you can tailor your SEO as needed.
NB! You do not need to change anything in your code for this app to work. It will however add meta description, Twitter Cards, and Open Graph meta fields even if you already added this in your code, so please remove those fields first! The logic behind adding a SEO friendly title is smarter and it will never insert duplicate <title>
tags.
This app introduces a number of global settings. They're controlled on the app itself (on your site content) and are used across the entire site, and/or as default fallback settings.
- General settings
- Twitter Cards
- Fallback settings
- Title config
- Advanced: prioritized JSON paths
"Generate Canonical meta?"
Turn generation of canonical meta field on or off. Default is off, since most sites ship with this already. If checked, it will generate the meta tag with current URL. The logic is simple, it will use the current content's path as value, something we know in Enonic XP always is unique.
"Google Search Console (site verification code)"
Add meta tag for Google Search Console (formerly known as Google Webmaster Tools). Just fill in your ID here to generate the proper tag on all pages. Consult your Google Search Console login for finding this ID.
"Hide site from search engines?"
We also introduce a setting for hiding the entire site from search engine robots. This might be handy when wanting to have a live beta site but not letting search engine index it. It's up to the search engines to respect this setting, and this setting does not hide the pages from outside visitors as links to them and direct URL's will still work.
For Twitter Cards to work we need a Twitter username (starting with @
). When that is in place we can generate meta data for improved Twitter sharing called "Twitter Cards". By omitting the username no such meta data will be generated.
This app tries to figure out which data to use for all the meta fields based on the current content. However, on some pages, there might not be any custom data set, like on your site's first page. That's what these settings are for: default fallbacks. Here is where you add a default image to fallback on for Open Graph and Twitter Cards, and any fallback title and meta description. If nothing is added here, and the app can't figure out any suitable data to use for a content, the meta fields are not generated at all.
With the title configuration you can control how we create the titles for you. If you already have a <title>
tag in your source html, we will overwrite it and use it's location in the source code. It's pretty clever this way. If you do not have this tag already, we will append it at the end of the <head>
-tag.
The settings here let you control if you want to add the site's name at the end of all pages' titles. You can activate this on all pages, but also control to not do this on the front page. There's also an option for controlling what separator sign to use between page name and site name (defaults to the dash character).
Note: Meta fields for Open Graph and Twitter Cards does not use these settings, it never adds site name to it's title meta field as it is redundant data.
When figuring out what data to put in your meta fields, this app analyzes the current content you're viewing. It will fetch a pre-defined set of fields in a pre-defined order (more on that later in the "Waterfall logic" section). You might however have fields with different names, or want to add more fields, or control in which order the data is evaluated. Then these settings are for you.
Add field names as comma separated strings, like field1, field2, long-fieldname3
. It will remove spaces and it will handle dashes and other special characters in your field names. These custom fields will be checked before any other fields. If you add more than one field here, we'll let the first one overwrite any other fields on its right hand side. So if we find data in field2
we won't look in long-fieldname3
. This gives you powerful control over your SEO!
We only evaluate for matches in the JSON data
-node for each content. So if you fill in myField
, we'll look for data.myField
in the content JSON (refer to Enonic XP's documentation on getContent()
function).
You can put a file on the server to configure all running instances of the app across one server. This is a feature that you can turn on and off per site through the app setting interface when adding the app (through the Don't overwrite values from app.config
setting). This means you can have the cake and eat it too!
Locate your $XP_HOME/config/
folder and create a file called app-metafields.cfg
and fill it with data like this, changing variables as needed (comment out the ones you don't need):
canonical = true|false
siteVerification = "xxx"
blockRobots = true|false
# This one is specific for the configuration file, use it when editing the app config in Content Studio to overwrite any configuration from this file.
# disableAppConfig = true|false
titleSeparator = "<3"
titleBehaviour = true|false
titleFrontpageBehaviour = true|false
twitterUsername = "@EnonicHQ"
# seoImage = "[AnyImageContentID]"
seoImageIsPrescaled = true|false
# frontpageImage = "[AnyImageContentID]"
frontpageImageIsPrescaled = true|false
seoTitle = "Fallback title"
seoDescription = "Fallback description"
pathsImages = "media.mediaImage.imgSrc, mediaImage"
pathsTitles = "data.customTitle, someField"
pathsDescriptions = "data.description, data.preface"
We will always add the meta fields for title and description, and most of the meta fields for Open Graph. However, if we cannot find any image to use, we won't add the meta fields for Open Graph image or Twitter Cards image.
It's important to understand the waterfall logic we use when evaluating which data to use for our meta fields (with the first match overwriting all the following ones):
- Current content's
SEO
mixin'stitle
field. - The app config's custom JSON paths, if any (in the order defined).
- Check in some commonly used fields:
title
,header
,heading
. - The content's
displayName
field (all content has this field). - See if the site itself has the
SEO
fieldtitle
filled out. - As a last resort, we default to the site's
displayName
field.
For titles there is no way it can be empty, at least the last fallback will always trigger.
- Current content's
SEO
mixin'sdescription
field. - The app config's custom JSON paths, if any (in the order defined).
- Check in some commonly used fields:
preface
,description
,summary
. - See if the site itself has the
SEO
fielddescription
filled out. - As a last resort, we default to the site's
description
field (default Enonic XP data). - An empty description is created.
- Current content's
SEO
mixin'simage
field. - The app config's custom JSON paths, if any (in the order defined).
- Check in some commonly used fields:
image
,images
. - Resort to the fallback image set on the app itself.
- If nothing is found the meta fields for the image are not created.
Version | XP version |
---|---|
1.7.0 | 6.15.0 |
1.6.0 | 6.15.0 |
1.5.0 | 6.15.0 |
1.4.0 | 6.7.0 |
1.3.3 | 6.7.0 |
1.3.2 | 6.7.0 |
1.3.1 | 6.7.0 |
1.3.0 | 6.7.0 |
1.2.0 | 6.7.0 |
1.1.4 | 6.7.0 |
1.1.3 | 6.4.0 |
1.1.2 | 6.4.0 |
1.1.1 | 6.4.0 |
1.1.0 | 6.4.0 |
1.0.0 | 6.3.0 |
0.5.0 | 6.3.0 |
- New: configure the app from configuration files on the server. Credit @edwardgronroos of TINE AS.
- Fix: Inject the
og:
namespace prefix definition in the<html>
-tag automatically.
- New: Handy widget that displays what data each content item will expose to Facebook and Twitter and Google bots.
- New: Possibility to override/add custom image per content.
- Fix: Automatically skip converting images to JPG if it's a SVG being used.
- Changed: Fieldset display-name is now only "SEO" instead of "SEO Metadata".
- Changed: Using new x-data format making SEO fieldset optional.
- Update gradle build-file to modern format.
- Require Enonic XP 6.15.
- Added config option to return separate fallback image for frontpage. Credit @nerdegutt
- Added config option to return raw (unscaled) fallback images for both frontpage and normal content. Credit @nerdegutt
- Using HtmlArea as description basis now possible, tags stripped. (#29)
- Changing the label for "hide from search engine". (#30)
- Handle nested userDefinedPaths and non-strings when overriding title.
- Bug fixed don't intercept content types other than html files. Can cause crashes on websites generating XML or JSON.
- Improve title behavior on clean installs of the app.
- Upgrade to Gradle 3.
- Greatly improved usability of app by adding help texts to all the fields.
- Changed the overall structure of settings for the app. Now with more logical groups (field sets).
- Gave multiple labels improved names, making it more obvious what they do.
- Improved documentation (this file).
- Regex force Twitter username to always begin with the @ symbol.
- Added default settings for front page behavior, it now starts as checked.
- Setting for "Append site name to title" now starts out as checked.
- Added "-" as the default page-site title separator.
- Added Twitter Card meta data generation.
- Added canonical meta data generation.
- Fixed bug where user-defined paths for meta description always failed.
- Fixed a bug on how multiple user-defined paths (for all scenarios) where trimmed (only first field worked if space characters where used between the commas).
- Prefer user-defined paths before content DisplayName, when generating titles.
- Updates to readme to reflect the new and improved "waterfall" logic (also contained some errors).
- Upgrade to version 6.7.3
- Better handle data from CMS2XP (empty data fields) for custom fields setting
- Fix some minor code consistency things
- Use the new lib-util library (1.1.1)
- Fix crash on page contribution handling on new sites
- Fix crash on "robot" toggle on new sites
- Added settings on app, and for all content, to "exclude from search" (robots)
- Added setting for Google search console (old webmaster tools)
- Improved handling of nulls, empties, and multiple app setups
- App is launched
- Renamed to SEO Meta Fields
- Multiple changes and improvements
- NOT compatible with the older versions
- First Beta-launch (as "Open Graph app")