Is it possible to make a pinned post linkable instead of a static page?

In order to create a static page, you first create a post and then pin it to convert it to a static page. This is great for creating additional pages such as “About”, “Contact” etc…but what if I wanted the pin to be an external link, this method doesn’t work. For example, I’ve created a “LinkedIn” static page which I wish would automatically go to my LinkedIn page instead of opening the static page which has the link in it.

You can do it with Javascript. This one is for the link to get a random post on my site.

/* Javascript for Random post Glitch app */
var a = document.querySelector('a[href=""]');
if (a) {
  a.setAttribute('href', '');
  a.setAttribute('title', 'Get a random post');
var b = document.querySelector('a[href="/dino/random"]');
if (b) {
  b.setAttribute('href', '');
  b.setAttribute('title', 'Get a random post');
1 Like

This might be a silly question, but where would the js script go since this is not a typical self-hosted site with access to linking js code etc…? Also the pinned post becomes a menu button, so how would it recognize the js code without having access to edit the html head tag?

On your blogs page there is a Customize option under your blog. When you click it, scroll down towards the bottom and you will see a “Custom JavaScript” area for JavaScript that can run on your blog (it only works for custom domains or domain). This is where you’ll put the code.

Would be glad to clarify further if needed!

1 Like

That worked beautifully. I made some adjustments to it for my needs:

var a = document.querySelector('a[href="MY_MENU_ITEM_URL"]');
if (a) {
  a.setAttribute('href', 'MY_NEW_URL');
  a.setAttribute('target', '_blank');    /*ADDED THIS FOR NEW TAB*/

cc: @cjeller1592

Thanks all!

1 Like