Fix email article for articles with apostrophes

Customers sometimes run into an issue where the email option does not work on certain articles. The most common culprit is an apostrophe in the article title, which breaks our legacy code for the email option.

 We've fixed the issue for new themes, but existing customers might still run into this issue. Luckily it's an easy fix!

  1. Go to Settings > Style.
  2. Below the preview pane, click on the Custom HTML  tab.
  3. In the Custom HTML dropdown, select Article to edit the article html template.
  4. Replace this section:
    <a href="#" onclick="javascript:window.location='mailto:?subject=[article("title")]&body=' + window.location;"><i class="fa fa-envelope-o fa-fw"></i></a>
    With this:
    <script>function sendEmail() {var title = '[article("title")]'.replace("'","\'").replace("'", "\'");window.location = 'mailto:?subject=' + title + '&body=' + window.location;}</script><a href="#" onclick="sendEmail()"><i class="fa fa-envelope-o"></i></a>
  5. Save.

Now you should be able to email those articles with apostrophes!