Misc Ghost Blog Improvements

The vanilla Ghost install generally requires some tweaks to fully meet the needs of its user or organization. Here are some modification I made to this blog in no particular order. This page will likely be updated in the future as the needs for further customization arise. One thing I will note is that I generally dislike manual modifications of the built in themes or the core code directly. If you find yourself modifying the theme files directly then I recommend copying the entire theme, giving the copy a modified name, install your new theme, and then modify that copy instead. If things go wrong you will want a clean and working theme to fall back on quickly without having to fiddle with ghost-cli or manually re-installing a built-in theme. Code changes that are bug fixes for ghost or ghost-cli should be submitted to the official Ghost developers on GitHub.

Add this to the global code injection footer to make all external links on a page automatically open in a new tab or window.

Make External Links in New Tab

<script type="text/javascript">
function makeExternalLinksTargetBlank() {   
for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) {
var b = c[a];
b.getAttribute("href") && b.hostname !== location.hostname && (b.target = "_blank")   } 
} ;
makeExternalLinksTargetBlank();
</script>

How does the syntax highlighting on this page work? Well that is done by injecting Prism.js into the page using the page/post scoped code injection header and footer.

Syntax Highlighting in Code Blocks

https://cdnjs.com/libraries/prism

function makeExternalLinksTargetBlank() {   
for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) {
var b = c[a];
b.getAttribute("href") && b.hostname !== location.hostname && (b.target = "_blank")   } 
} ;
makeExternalLinksTargetBlank();