Jump to content

MarkupSEO - The all-in-one SEO solution for ProcessWire.

Nico Knoll

Recommended Posts


Thanks for adding it. I'll take a look.


Select a custom field with a fallback to title?

You can use multiple smart titles. So the first one will be used if filled (https://github.com/NicoKnoll/MarkupSEO/blob/master/MarkupSEO.module#L182-L187). If not the second one is used and so on. "Smart title" will be used in case you leave the "Title" field in the SEO tab empty.



Yes it's $page->httpUrl by default (https://github.com/NicoKnoll/MarkupSEO/blob/master/MarkupSEO.module#L233). But you're right. I should add a comment.

URL Segments

I'm not sure either how to handle them. But as they are not "real" pages I guess this module isn't able to handle them anyway (you can't add SEO fields to non existing pages...)

link rel="alternate" hreflang

I'll add an option to include this :)

  • Like 1
Link to comment
Share on other sites

Hi Nico,

Thanks for this module! Love it much :)

I think I may have found a conflicting issue when this module is installed along side with ProcessBackup (DB Backup module). There is an error when you try to view the Database Backup detail and I believe it may be caused by the following line:

$editedPage = wire('pages')->get($this->config->input->get->id);

The SEO module kicks in when trying to view the database backup page because there is a querystring id in the url.


The fix is pretty simple:

    public function ready() {
      // backend hooks
      if(@$this->page->process == 'ProcessPageEdit') {
        $editedPage = wire('pages')->get($this->config->input->get->id);

        if(in_array($editedPage->template->name, $this->includeTemplates)) {
          $this->addHookAfter("ProcessPageEdit::buildFormContent", $this, 'hookCustomizeSeoTab');

      // frontend hooks
      if($this->page->template != 'admin' && in_array($this->page->template->name, $this->includeTemplates)) {
        $this->addHookProperty("Page::seo", $this, 'hookFrontendPage');
        $this->addHookProperty("Config::seo", $this, 'hookFrontendConfig');

Check the ProcessEditPage first before look for the edited page object. But anyway, I thought I let you know :) Thanks much again!

  • Like 3
Link to comment
Share on other sites

Hi Nico,


>Yes it's $page->httpUrl

I see a potential double content problem here:

A page can exist in http and in https mode. Especially after a https page was called (admin area, or a form in the frontend for example) a user stays in https mode until a next page which is set as http-only was opened.

Do you agree that a double content issue is possible?

If so, my idea would be using this checking order:

1. is the whole site https only (the brand new setting option in the latest dev) ->https

2. fallback: is there a strict setting in the URL part of the template for https? ->https

3. fallback: use the common way to display a website ->http

What Do you think?

Link to comment
Share on other sites

If so, my idea would be using this checking order:

1. is the whole site https only (the brand new setting option in the latest dev) ->https

2. fallback: is there a strict setting in the URL part of the template for https? ->https

3. fallback: use the common way to display a website ->http

I would support such a process, as google is suggesting webmasters to use https. I don't know for sure about the state of improved rankings from https, but as it's a possible factor, it should be taken care of as best as possible.

Link to comment
Share on other sites

URL Segments

I'm not sure either how to handle them. But as they are not "real" pages I guess this module isn't able to handle them anyway (you can't add SEO fields to non existing pages...)

Personally I'm not using the SEO module, I set it up in my _init.php, and when using URL Segments I add it in my templates.

Correct me if I'm wrong, but using URLSegments you actually have to edit the template, since it's not an actual page and doesn't have a title and/or meta_descriptions can't you create some default fall-back when URL Segments are used?

Then in the template itself:

SeoModule->fallback_string(__('%1$s is part of %2$s and contains %3$s subpages'),$URLSegment1, $page->parent->title, count($page->children));

or as matter as fact any default outcome when a $page->name/$page->core.title doesn't exist at all...?

BTW above "code" is just fiction, but I guess you know where I'm going...

Now we're at it, URL Segments aren't included in the current sitmap xml module either, which is not ideal on a SEO point of view.

Link to comment
Share on other sites

@makari: You now have to define which templates should get a SEO-tab in the module's settings :)

I did it. But no SEO-tab anywere... :mellow:

I guess, some of the old versions data is left in the database - but how can I find that - and where?

Link to comment
Share on other sites

Version 0.7.0:

Hey, I added the https option you asked for:


$config->https will be set to true in runtime I guess if the template is set to use https, too. So all of the fallbacks should be covered.

And I added the fix by @peterfoeng.

  • Like 1
Link to comment
Share on other sites

I'm not getting an SEO tab appear on my publish/edit pages. I'm also not seeing any seo_xxxx fields in my fields list. So I thought I should maybe uninstall and reinstall, but when I try to uninstall I get:

Recoverable Fatal Error: Argument 1 passed to Fields::___delete() must implement interface Saveable, null given (line 265 of /wire/core/Fields.php) 
This error message was shown because you are logged in as a Superuser. Error has been logged.

And yes, I have specified templates to get the tab in the module's settings.

Link to comment
Share on other sites

Thanks for this module.

I use smart fields and got a little bit trouble using the description field. Because I chose fields which include html tags. Even if if I check "Strip Tags" in the field settings for seo_description. I guess that this setting doesn't take effect if the field was left blank. This results in:

<meta name="og:description" content="<h2>KF Interactive GmbH</h2>
	D-04107 Leipzig</p>
	<p>Tel.: +<br />
	Fax: +<br />
	Mail: <a href=" mailto:info@kf-interactive.com"="">
<p><strong>Konzeption und Gestaltung der Website:</strong><br>
	<a href=""></a> & KF Interactive</p>

.. and breaks the layout.

I changed line 206:

-             $pageData['description'] = $page->get(implode('|', $configData['descriptionSmart']));
+             $pageData['description'] = strip_tags($page->get(implode('|', $configData['descriptionSmart']))); 

.. and everything works  :)

Maybe you could include this litte fix in a later version?

  • Like 4
Link to comment
Share on other sites

Regarding the HTTPS option:

$pageData['canonical'] = preg_replace('%^http%Uis', 'https', $page->httpUrl);

should be

$pageData['canonical'] = preg_replace('%^https?%i', 'https', $page->httpUrl);

This way the regex will capture all of the protocol string regardless of whether it is http or https at this stage. In my case I got a httpss in the resulting links from the first one as it matched the http, when the input was https.

Tried a few other regexes (e.g. https?, etc.) as well which logically should've worked, but preg_replace in its true self proved to be inconsistent.

Scratch that - read over the U modifier.

Fix returns https for both http and https as input, so covers both eventualities in the context of where it's called in the codebase.

  • Like 1
Link to comment
Share on other sites

Had to add a character counter with limiting functionality for one of my projects. Take a look and let me know what you think for now https://github.com/pjguk/MarkupSEO

No guarantees given - this was "hacked" straight into a production environment which already utilises the module and therefore uninstalling and reinstalling was not an option for the time being.

Particulars that are most likely not working as expected for now (Couldn't reliably test yet):

  • Default character limits are not set on install
  • Default character limits do not set should the limit field be empty when the page is saved
  • Hard character limits do not apply to pages unless the fields are being edited and the page subsequently saved (requirement for my project, may not be the behaviour everybody wants/needs)

So still some teething problems with the config on that part, but works well enough for me for the time being.

The modifications allow the following:


Counter added to the title and description fields in the SEO tab. Counting down from the limit to 0 - and beyond to show how many characters you are over.


Config options in the module settings to set the character limits for title and description as well as toggling hard limits. Hard limits disable the ability to enter more than the limit number of characters. Useful if multiple authors work with the SEO tabs and you want to ensure nobody goes over the limits.


With hard limiting disabled the character counter simply goes into the negative and ignores the limit for the actual input and render.


With hard limiting enabled the input cuts off at 0 characters left.

  • Like 1
Link to comment
Share on other sites

@tyssen: if you can't delete it go to fields and delete all of the (remaining) seo fields manually. Then go to the modules code and delete the whole ___delete() function. Then uninstall the module and delete the .module file. Then download the most recent version (0.8.1), install it and let me now if it works better afterwards :)

Link to comment
Share on other sites

This module cause a conflict with pages on the front end that use the id variable.

"../json_pages/?id=234|434"  will crash processwire. 

this seems to be the caused by: LINE: 92.

$editedPage = wire('pages')->get($this->config->input->get->id)

I think checking that you are in the backend before running the above query might solve the issue.

btw, great plugin. 

  • Like 1
Link to comment
Share on other sites

All good now, thanks. And very nice module, previewing feature especially.

Just one small request: it would be useful to have a way to override the Title Format on certain pages, e.g. the home page. For most pages I'll want to have Page Name – Site Name, but on the home page I'll want to have Site Name – Site Description, but with title format enabled I get Site Name – Site Description – Site Name.

  • Like 1
Link to comment
Share on other sites

Thanks for adding strip_tags for smart fields  :)

I got a little bit of trouble regarding the new piwik including. Still after re-saving the module settings I get the following error:

Notice: Undefined index: piwikAnalyticsUrl in /.../public/site/modules/MarkupSEO/MarkupSEO.module on line 311

On line 311 you need to check first if this array key exists because in the database there is just an entry for "piwikAnalytics":"" initially. As a quick fix I added ,"piwikAnalyticsUrl":"" manually.

Changing line 311 to

if (array_key_exists('piwikAnalyticsUrl', $configData) && $configData['piwikAnalyticsUrl']) 

or  check if piwikAnalytics is not empty

if (!empty($configData['piwikAnalytics']) && $configData['piwikAnalyticsUrl'])

should solve this issue.

Link to comment
Share on other sites

You corrected the names and therefore an empty entry will be saved. That's on line 767  ;) So you don't have to extend the if condition I suggested (on line 311) because you know that there is always an entry with this key.  ;) Thanks for the quick fix.

(I've been waiting for the strip_tags fix to be able to reset my deployment script because your module is included as a git submodule and I didn't want to change this. So I was quite sure to use the latest master version.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.

      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      ProcessWire module directory
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
  • Create New...