CODE

Anti‑Spam Blog Comments

ESTIMATE 2-MINUTE READ

Spam Protection

Pin

Do your blog articles include an option to leave a comment? If so, many visitors may pack it with SPAM or troll remarks. As a defense, Shopify comments (among more robust alternatives) include a moderation feature. The site administrator can read and approve visitor comments before they show up in the blog.

Approve More Comments

Many comments that begin with a nice message remain unapproved because they include URLs or other HTML formatting. With a simple modification to your Shopify theme, you can strip out the HTML and truncate the comment when encountering a URL. For this, use the programming language called Liquid.

Before making modifications to your Shopify theme, it is good to duplicate it. Within Admin, under the lefthand navigation, choose Online Store: Themes. Click the menu for the active theme, Actions: Duplicate. Work on the duplicate and preview before activating when done.

Now you access the Liquid programming code with Actions: Edit code menu. Within the Sections area, open your article-template. (For older themes without a Sections area, open the article.liquid under the Templates section.)

Scroll to the bottom to insert the following code:

Login For Code

This allows the blog author to leave unrestricted comments (with a URL) but prohibits others from doing so. (Shopify retains the full comments but only displays the truncated versions with this modification.)

Blogs have their value from an SEO standpoint. With the proliferation of multimedia social media platforms, reading words for entertainment may seem to be as esoteric as opera audiences. Most visitors scan a page of text in under a minute, looking for videos, subheads, and pull quotes to get the gist of what is going on.

Include Meaningful Comment