How to edit/modify the default.hbs file

Hi there

Am a newbie here and hoping the more learned members can help.

I am trying to add a ‘Back to top’ button and code to our website (which use the default Casper theme) but I am unable to find how to access the default.hbs file into which I understand I must inject the relevant code (which I have prepared).

Would someone be able to provide the steps to access this directly, and if it is a case of downloading the file, editing locally and then uploading back to ghost.io, then please provide the export/import steps.

I am assuming that if it is a case of download, edit, upload, I should make a copy of the pre-update file, and keep it safe so that if the edit does not work or is not what is expected then I can just upload the copy to revert to the website state prior to uploading the updated default.hbs file.

Many thanks in anticipation.

Kind regards,

Grendell

If you have directions for code injection, you do that from /ghost > settings (gear icon) > code injection.

If you’re following directions to edit the theme, then yes, you’ll download, unzip, edit, rezip, and upload. There are a number of tutorials on theme editing over in Tutorials that will get you started!

Hi Cathy

Many thanks for the pointer…I will investigate.

But may I check on one key point for me…is it good practice to export one’s site and keep a copy safe, so as to be able to import it at a later date if something happens to the site?

Or is there a better way to achieve the same end…website recovery in case of issue, etc.?

Many thanks for your assistance in this matter. It is much appreciated.

Regards, Grendell

Exporting your site makes a backup of your posts and pages and config settings. (Not images.) it does NOT back up your theme files. And uploading/downloading theme files will not harm content. They’re separate. Certainly it’s a good idea to maintain a backup copy of your theme files before editing, in case you want to go back to something you had before.

Hi Cathy

Thanks for the prompt response. However, I am a bit confused by it…so would just like to make sure I am straight here.

  1. Exporting one’s site makes a backup of posts, pages & config settings but NOT images.
  2. And it does NOT back up one’s theme files.

So, if one is editing the theme files, i.e., default.hbs, for example (have I got that right that this is one of them?), then how does one create a backup copy of the theme files.

What am I missing/getting wrong re. my understanding…apologies I am a newbie on a big learning curve.

Thank you for your patience…it is appreciated.

Regards, Grendell

In order to edit the theme you’re going to download it anyway. So you just save an unedited copy.