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

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 redirect based on the URL but like all rules, you can also redirect based on a regular expression, on the Joomla component or a category, on a custom field value, or even only between 2 dates! To learn more, see all the options to trigger a rule, any rule, on the When to run 4SEO a rule page.

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 https://weeblr.com by selecting Link as the Replacement type.

Depending on the type of replacement you pick, specific additional options will appear:

Options for Text replacments

There are two options for Text replacement:

Options when replacing some text with some other text

  • Protect links: if enabled, 4SEO will not perform the replacements inside of href and src attributes of links, thus preserving the URL in the links
  • Protect Hn tags: if enabled, 4SEO will not perform the replacements inside of Header HTML tags such as <h1> or <h2>. This lets you be more selective and only perform replacement in the text body

Three more options appear for you to select details of the link construction:

Options when replacing some text with a link

  • Protect Hn tags: see above
  • Open link in a new tab: the created link will have rel=nopener target=_blank attributes
  • No follow the link: the created link will have a rel=nofollow attribute

Replacement Scope

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

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, in the head or body HTML sections of the page or even in metadata.

Options to decide where to look for content to replace

If you select Metadata, a new selector appears to let you pick a specific metadata element:

Options to limit what to replace and where

Note that when doing a replacement in metadata, you can only use simple text. Turning a word into a link is not available.

Replacing in OpenGraph title or description is typically used to turn a word into a hashtag, ie Joomla! into #joomla for instance.

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 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 links such as https://www.joomla.org 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.

Built-in shortcodes

To help you in common situations, 4SEO comes with a number of built-in shortcodes that will be replaced automatically.

You do not need to create any rule for this to work, simply insert them in any kind of content and 4SEO will replace them when rendering the page.

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 username, 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

Joomla article information

On Joomla articles pages, 4SEO will replace the following shortcodes with the corresponding information"

  • {4seo_article_id} : The internal, unique id of the article
  • {4seo_article_title} : The article title
  • {4seo_article_description} : The article description entered the Description field of the publishing tab, if any
  • {4seo_article_date_modified} : The article last modification date, using the YYYY-MM-DD HH:MM:SS format
  • {4seo_article_date_published} : The article publication date, using the YYYY-MM-DD HH:MM:SS format
  • {4seo_article_category_id} : The internal, unique id of the category the article belongs to
  • {4seo_article_category} : The title of that category
  • {4seo_article_author} : The name of the article author
  • {4seo_article_rating} : The average rating of the article
  • {4seo_article_rating_count} : The number of ratings for that article
  • {4seo_article_hits} : How many times the article was rendered by Joomla

Hikashop information

On Hikashop pages, 4SEO will replace the following shortcodes with the corresponding information

  • {4seo_product_name} : The product full name. Only on product pages
  • {4seo_product_description} : The product description, if any. Only on product pages
  • {4seo_product_brand} : The product brand, if any. Only on product pages
  • {4seo_product_price} : The product price, including currency. Only on product pages
  • {4seo_product_sku} : The product Stock Product Unit or product code. Only on product pages
  • {4seo_product_condition} : The product condition. Only on product pages

J2 Store information

On J2 Store pages, 4SEO will replace the following shortcodes with the corresponding information

  • {4seo_product_name} : The product full name. Only on product pages
  • {4seo_product_description} : The product description, if any. Only on product pages
  • {4seo_product_brand} : The product brand, if any. Only on product pages
  • {4seo_product_price} : The product price, including currency. Only on product pages
  • {4seo_product_sku} : The product Stock Product Unit or product code. Only on product pages