Skip to content

Content replacement

4SEO content replacer is avery powerful feature that lets you replace specific bits of content with something else. For instance, it can be used for:

  • change words or names globally without having to modify dozens of articles or products description
  • link automatically a word or phrase to another page
  • remove offensive words if you accept user comments for instance
  • hide or modify some content before, after or between dates
  • use your own abbreviations or built-in shortcodes, replacing them with simple text or HTML code
  • even fix some HTML, javacript or CSS code inside pages when not having access to the source

Built-in shortcodes

To help you in common situations, 4SEO comes with a number of built-in shortcodes that will be replaced automatically. You can simply insert them in any kind of content. They all look like {4seo_xxxx} with various options for xxx:

Here is a full list of currently supported shortcodes:

Site information

  • {4seo_site_name} : The full website name
  • {4seo_site_url} : The web home address

Page information

  • {4seo_page_url} : Current page fully qualified URL
  • {4seo_page_canonical} : Current page canonical URL, if any
  • {4seo_page_custom_canonical} : Current page custom canonical URL, if any
  • {4seo_page_auto_canonical} : Current page automatically computed canonical URL, if any
  • {4seo_page_robots} : Current page robots meta tag, if any
  • {4seo_page_custom_robots} : Current page custom robots meta tag, if any
  • {4seo_page_language} : Current page language tag
  • {4seo_page_language_direction} : Current page language direction (ltr or rtl)
  • {4seo_page_title} : Current page title
  • {4seo_page_custom_title} : Current page custom title, if any
  • {4seo_page_description} : Current page description, if any
  • {4seo_page_auto_description} : Current page automatically computed description, if any
  • {4seo_page_custom_description} : Current page custom description, if any

User information

  • {4seo_user_id} : Current user id, empty if not logged-in
  • {4seo_user_name} : Current user name, empty it not logged-in

Date and time information

  • {4seo_year-month-day} : Current date formatted as YYYY-MM-DD
  • {4seo_year-month-day_time} : Current date and time formatted as YYYY-MM-DD HH:MM
  • {4seo_day/month/year} : Current date formatted as DD/MM/YYYY
  • {4seo_day/month/year_time} : Current date and time formatted as DD/MM/YYYY HH:MM
  • {4seo_year} : Current year formatted as YYYY
  • {4seo_year-month} : Current month formatted as YYYY-MM
  • {4seo_month/year} : Current month formatted as MM/YYY
  • {4seo_month_name} : Current month full name
  • {4seo_month_short_name} : Current month short name
  • {4seo_month_number} : Current month number, from 1 to 12
  • {4seo_month-day} : Current day and month, formatted as MM-DD
  • {4seo_day/month} : Current day and month, formatted as DD/MM
  • {4seo_week_number} : Current week number
  • {4seo_day_name} : Current day full name
  • {4seo_day_short_name} : Current day short name

Replacement rules configuration

To select which pages you want to replace content on, select With some conditions on the When to run tab of the rule creation page:

Sample condition to replace some content on

In this example, we have entered /blog/{*} in the pages URL field. This will cause content to be replaced only on pages which URL starts with /blog/

Other specification for where to replace content inside a given page, ie only in the body, in main content or modules, can be set on the What to do tab of this replacer rule dialog.

This example triggers a replacement based on the URL but like all rules, you can also run the replacement rule based on the Joomla component or a category - or even only between 2 dates

Replacement source and target

The What to do tab is where you describe exactly what you want to replace and with what. In the simplest form, just enter some text in Replace what? and Replace with what? and 4SEO will do an exact replacement on all pages selected for that rule.

Simple rule to replace one string with another

Either field can contain just simple text but also HTML code. This can be used to insert custom HTML code or expand your own abbreviations.

Regular expressions

You can also use regular expressions in the Replace what? input by directly entering your regular expression in that field. You must however use the ~ character as your regular expression delimiter. An example input would be: ~/contact-us/.*~

As the replacement can be scoped to only some pages, or a period of time, it means you can create different content on different part of the sites

Replacement Type

By default, 4SEO will simply use the text your enter in the Replace with what? field to replace the original text. However, you can also specify to turn a piece of text into a link. Here is an example configuration to automatically create links:

Rule to replace some text with a link

In this example, we replace any instance of Weeblr llc with a link to by selecting Link as the Replacement type.

When you do so, two more options appear for you to select details of the link construction:

  • Open link in a new tab
  • No follow the link

Replacement Scope

Finally, you have even more fine-grained control for what to replace and where with the last options section:

Options to limit what to replace and where

Where to look for that text

By default, 4SEO will search for the desired text in the Main content and that is the main piece of content (article, product) on a page. Modules or non-visible parts of the page would be excluded.

But you can select to either search for the source text anywhere on the page, only in modules or even in the head or body HTML sections of the page.

Case sensitivity

Select whether 4SEO should search for your source text only if there is an exact case match, or if case does not matter.

Default is to search regardless of case, meaning the entering Weeblr llc in the What to replace? field will replace all of the follwing:

  • Weeblr llc
  • weeblr llc
  • weeblr LLC

Whole words only

By default, 4SEO will only replace whole words. If you ask it to replace enter, then it will replace it in I enter the room but NOT in I am entering the room because in the latter, the word enter is not a whole word, it's part of the entering word.

You can change this behavior if useful to you, although it likely won't be the most common situation.

By default, 4SEO will not apply your replacement rule on URLs found inside of links.

For instance, even if you want to replace the word Joomla with Joomla! in your regular content, you probably do not want to do that inside of link such as as it would break that link.

You can disable this option if you specifically want to modify links in content. This can be used to fix some old links where you know precisely the old and the new addresses as it is more efficient, SEO-wise, to use the correct link than a redirect for instance.

This option is only displayed for text replacement. When the replacement type is set to Link, 4SEO will never modify existing links or even HTML tags, as this would produce invalid html content.

Maximum number of replacements

Whenever a rule is executed on a given page to replace some content, you can limit the number of replacements done. If the Replace what? text is present multiple times on the same page, all instances will be replaced by default - well, up to 99999 times actually!

But if you enter a number here, say 5, only the first 5 instances of your target text found on a page will be replaced.

Entering a zero value will limit the number of replacements to none, meaning that in practice the rule is disabled. If you want to prevent the rule to operate, it is more efficient to actually disable the rule itself on the When to run panel.