Security Sense

Personal ramblings of a security professional

Open link in new tab markdown shortcode

2018-03-02 Code Tutorials Simon

After some Googling I found that the majority of examples of trying to open a link in a new tab from within a blog article didn’t work with the Markdown engine within Hugo.

To that end I have come up with the following custom shortcode to achieve this.

Firstly create a folder named shortcodes in your site layouts folder. The name is case sensitive and yes it does have an s on the end.

Within that folder create an html file with a suitable name, for example:

open-in-blank.html.

The contents of the html should be as follows:

<a href="{{ .Get 1 }}" target="_blank">{{ .Get 0 }}</a>

When you write your blog article and want the link to open in a new tab you should use the following syntax utilising the name of the shortcode html file you created without the file extension e.g open-in-blank:

{{< open-in-blank "Github" "https://github.com/SecuritySense/" >}}

The text between the first quotes is the text that is displayed within the post with the second quoted text being the URL to open.

The posting can also be found at my Github

Obfuscated Email Contact Form

2018-02-19 Code Tutorials Simon

This code implements a web contact form in Javascript which utilises Formspree and the inclusion of an obfuscated email address using the email obfuscator script v2.1 by Tim Williams, University of Arizona and can be found at my Github

To create the obfuscated email code visit the following link and enter your email address then copy the code between the <!-- and //--> tags into the Main-Javascript.js code.

Once implemented on your web site submit a message via the form and as this is the first submission you will be asked to confirm your email address by Formspree.

Formspree sign-up process for contact form email

The Formspree service is free and details can be found at https://formspree.io/

Thanks go out to Tim Williams and Andrew Moulden for the obfuscation script as well as Michel Plungjan @mplungjan for the contact form code.