Krabi Documentation
Current Version:1.1.0 — 22 March 2021
Changelog →
Theme Editing & Tools
Edit the theme files mentioned here with your text editor of choice. For example, you can use Visual Studio Code ↗ or Sublime Text ↗.
Once you finish making your changes, zip the theme files, and upload the final zip file to your Ghost website.
If you are looking for Ghost hosting, I recommend Ghost(Pro) ↗.
Watch the following short video tutorial about theme editing.
Table of Contents
- Theme Installation
- Upload the routes.yaml File (⚑ Required)
- Create a New Content API Key (⚑ Required)
- Members / Subscriptions
- Navigation
- Search
- Pages
- Comments
- Show Authors
- Posts Per Page
- Related Posts
- Google Analytics
- Update Favicon
- Responsive Tables
- Social Sharing Icons
- Sidebar Social Media Icons
- Languages
- Syntax Highlighting
- Theme Deploy with GitHub Actions
- Code Injection
- Changing Colors with CSS Variables
- Customize Image Height
- Customize Logo Size
- Center Post Page
- Add Custom Homepage
- Show Full Post Content Instead of an Excerpt on the Homepage
- Remove Date from All Posts
- Add a New Sidebar Widget
- Change Subscribe Box Background Icon
- Remove Subscribe Box at the Bottom of a Post
- Fixed Header
- Open Post Links in a New Tab
- Add Table of Content
- Change Blockquote Style
- Homepage Two Column Posts
- Changing Theme Font
- Loading Custom Font
- Theme Development
- Theme Update
Theme Installation
The first step is to unzip the downloaded package. Inside the new directory krabi, you will find the zipped theme and a documentation file.
Follow these steps to upload the theme to your website:
- Log in to your Ghost website admin (example.com/ghost).
- Click the settings icon ( ) at the bottom of the left hand side.
- Go to Themes.
- Scroll down to the INSTALLED THEMES section.
- Click Upload a theme.
- Select the theme file (krabi.zip).
- Once uploaded, click Activate now to activate the theme immediately. If you want to activate it later, click Close.
Upload the routes.yaml File (⚑ Required)
The routes.yaml
file is required for member sign up, and subscription flows.
To upload the file, follow these steps:
- Unzip the
krabi.zip
theme file. - Go to the Labs page in Ghost admin (
/#/settings/labs
). - Scroll down to the Routes section and click the Upload routes YAML button.
- Select and upload the
routes.yaml
file inside the theme folder.
Note: upload routes.yaml after uploading the theme zip
There will already be a default routes.yaml
file uploaded to Ghost. You need to upload your theme’s routes.yaml
to override the default.
Do this separately after uploading your theme zip file.
Create a New Content API Key (⚑ Required)
To enable certain features, like Search, you’ll need to create a new Content API Key. Follow these steps to create your key.
In the left-side menu of your Ghost admin, click Integrations then + Add custom integration.
Give the new integration a name, like “Search”, and click Create.
A new content API Key will be created. When you hover over it, a Copy button will appear. Click the button to copy the key to the clipboard.
Next, click Code injection from the left-side admin menu.
After replacing the API_KEY
value with your API Key, add the following code to the Site Header box:
<script>
var search_api_key = 'API_KEY';
</script>
It should look like this:
Click Save.
Members / Subscriptions
Make sure to Upload the routes.yaml file.
Krabi has different user interface elements for membership feature.
- Log in and Subscribe buttons in the header
- Sidebar and Footer subscription forms
- A post subscription form
- Call to action section on the post page to encourage visitors to subscribe if the post is for members only
If the user is already logged in, all the forms will be hidden automatically.
Remove ‘Log in’ and ‘Subscribe’ from Header
To remove Log in and Subscribe from the header, open the partials/header.hbs
file and remove lines 30
to 36
. This will also remove the Account and Log out links.
Remove ‘Public’, ‘Members’ and ‘Paid’ Labels from Post Card
Open the partials/post-card.hbs
file and remove lines 23
to 27
.
Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
Or, copy and paste the following CSS code into the Ghost admin Code Injection Site Header.
<style>
.c-post-card__visibility { display: none; }
</style>
Remove Subscribe Form From Sidebar
To remove the Subscribe form from the header, open the partials/sidebar.hbs
theme file and remove line 2
.
Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
Remove Subscribe Form From Site Footer
To remove the subscribe box from site footer, open the partials/footer.hb
theme file and remove lines from 18
to 23
.
Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
Remove Subscribe Form From the Article Page
To remove the subscribe box on the article page. Open the post.hbs
file and remove lines from 28
to 38
.
Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
Edit Plan Features
To edit plan features, edit the partials/member-plans.hbs
file.
The free plan column will be visible to guest users when they visit the /subscribe/
page.
To remove this column, open the partials/member-plans.hbs
file and remove lines 2
to 17
.
Clicking the Free button will direct the user to /signup/
.
If logged-in users try to subscribe to a plan from their account page, only the monthly and yearly plans will display.
Membership Troubleshooting Tips
If for any reason the subscribe form does not work, or there is an error message, the following tips might help:
If you are self-hosting your website, make sure to set up the mail config ↗. After doing that, restart your Ghost server.
The website config URL should match the URL used to access the website, as described in the Ghost docs ↗.
Enter the URL that is used to access your publication. If using a subpath, enter the full path, https://example.com/blog/
. If using SSL, always enter the URL with https://
..
For more information about Members, connecting Stripe, and setting the package price, check the official Ghost documentation ↗.
Navigation
You can add, edit, delete, and reorder menu links on your Ghost blog in the NAVIGATION section (Admin > Settings > Design).
To include a static page on your navigation menu, follow these steps.
First, type the page’s name as you’d like it appear on your menu in the label field.
Next, click on the item’s URL. The blog URL will already be auto-populated. Add the page slug after the final /. When you’re satisfied with your page configurations, click the blue Save button to add the page to the navigation menu.
Header Tags Menu
The tags menu will automatically show all the blog tags in alphabetical order.
Remove Latest Tab
If you want to remove the Latest tab, open the partials/tags-list.hbs
file and remove lines 7
to 9
.
Change the Wording or URL on the Latest Tab
If you want to change the wording on the Latest tab, open the partials/tags-list.hbs
file and change line 8
link text. So, for example, if you want to replace Latest with Home, you can do the following.
<a href='/' class='c-tags-list__link'>Home</a>
As shown above, the Latest tab URL will point to the homepage. If you want to point to another page, change the link href
attribute /
value to your new URL. For example.
<a href='/topics' class='c-tags-list__link'>Home</a>
Show Specefic Tags
If you want to only show specific tags, open the partials/tags-list.hbs
and replace line 4
with the following line after replacing each TAG_SLUG
with your tag Slug.
{{#get 'tags' limit='all' filter='slug:[TAG_SLUG, TAG_SLUG, TAG_SLUG]'}}
So, if you have tag slugs like tech-vc, design, coding, it should be like:
{{#get 'tags' limit='all' filter='slug:[tech-vc, design, coding]'}}
Note the Comma (,
) separating each slug.
Note
If the tag is empty with no posts, it will not be visible. Add the tag to any post, and it will appear.
This way does not guarantee to get the same tags in the same order as you added the slugs. Probably a Ghost issue.
Show List of Pages Instead of Tags
If you want to show a list of static pages instead of the tags, open and edit the partials/tags-list.hbs
theme file.
Instead of the current tags loop code, remove all the Handlebars lines and use the existing HTML markup to add your pages as list items.
So instead of the following code.
{{#get 'tags' limit='all'}}
<div class='c-tags-list-wrap'>
<ul class='c-tags-list o-plain-list dragscroll'>
<li class='c-tags-list__item'>
<a href='/' class='c-tags-list__link'>{{t 'Latest' }}</a>
</li>
{{#foreach tags}}
<li class='c-tags-list__item'>
<a href='{{ url }}' class='c-tags-list__link'>{{ name }}</a>
</li>
{{/foreach}}
</ul>
</div>
{{/get}}
Your code might look like the following.
<div class='c-tags-list-wrap'>
<ul class='c-tags-list o-plain-list dragscroll'>
<li class='c-tags-list__item'>
<a href='/productivity/' class='c-tags-list__link'>Productivity</a>
</li>
<li class='c-tags-list__item'>
<a href='/career/' class='c-tags-list__link'>Career</a>
</li>
</ul>
</div>
Remove Tags Menu
If you want to remove the entire tags list, open the default.hbs
and default-wide.hbs
files and remove line 12
from both of them.
Secondary Footer Navigation
Similar to Header Navigation, you can add the footer navigation from the SECONDARY NAVIGATION section (Admin > Settings > Design).
Search
Make sure to create a new Content API Key.
The theme uses ghostHunter.
The search goes through the Post title and the content. It supports only Posts, not Pages.
The supported languages are German, Spanish, French, Portuguese, Italian, Finnish, Dutch, Turkish, and Danish.
ghostHunter Slow Search
If you have a large amount of content on your website, the search might become slow.
The issue is that Ghost does not have a built-in search feature ↗ so, to solve this and add search, a third-party library is used. In this case, the ghostHunter ↗ library.
This solution works well for most websites, but if the content is too large, it becomes a bit slow as the search happens on the user browser side, and all the data will be loaded before the search is happening.
There are currently two solutions:
1. Search only on the post title and ignore the content
This will improve search performance and reduce the loaded content. If this sounds fine, download this app.min.js ↗ file and replace it with your theme assets/js/app.min.js
.
For reference, what I did was removing the post text from the request API in the assets/js/ghosthunter.js
theme file. So line 108
becomes the following.
var url = site_url + "/ghost/api/v4/content/posts/?key=" + search_api_key + "&limit=all&fields=id,title,excerpt,url,published_at,feature_image";
Instead of.
var url = site_url + "/ghost/api/v4/content/posts/?key=" + search_api_key + "&limit=all&fields=id,title,excerpt,url,published_at,feature_image&formats=plaintext";
This is done in the theme development mode to generate the final app.min.js
file loaded in the theme.
2. Using another search tool
Use another tool like Google Search, Elasticsearch, or Algolia. I have not tried them out, but here are a few resources at Ghost ↗.
Pages
Manage pages for Tags, Authors, and Contact from the Pages section of Ghost admin.
Tags Page
Follow these steps to create the Tags page:
- From the Ghost admin Pages section, create a new page and give it a title, like “Tags”.
- From Page settings, select the Tags template.
- Publish the page.
- To add the page to the navigation, please check the Navigation section above.
Note for Self-hosters
If you are self-hosting your website, you may need to do a server restart. This should get the Tags option to show up in the Template dropdown.
Authors Page
To create the Authors page:
- Create a new page and give it a title, like “Authors”.
- From Page settings, select the Authors template.
- Publish the page
- To add the page to the navigation, please check the Navigation section above
Note for Self-hosters
If you are self-hosting your website, you may need to do a server restart. This should get the Authors option to show up in the Template dropdown.
Contact Page
To create the Contact page:
- Create a new Page and give it a title, like “Contact”.
- Add your content and the contact form code using Formspree ↗ as a service. Please check the code example below.
- Publish the page.
- To add the page to the navigation, please check the Navigation section above.
<form action="https://formspree.io/your@email.com" method="POST">
<input type="text" name="name" placeholder="Name">
<input type="email" name="_replyto" placeholder="Email">
<textarea name='message' placeholder="Message"></textarea>
<input class='c-btn' type="submit" value="Send">
</form>
For more information, check out How to Add a Contact Form to Your Ghost Blog.
Comments
The theme supports comments from Disqus, Commento, and CommentBox.
If you display comments for logged in users only, they will need to login/register into the comment system again. As you know, Ghost has no comment system, and these are third-party tools that are not integrated with and not part of Ghost.
For questions or issues about the commenting systems here, please contact their authors or check out their documentation.
Disqus
To enable Disqus ↗ as a comments system, open the partials/disqus.hbs
file. Replace the aspirethemes-demos
value with the disqus_shortname
variable to match your Disqus account shortname.
var disqus_shortname = 'aspirethemes-demos';
So, if your Disqus shortname is exampleone
, the final code above should be:
var disqus_shortname = 'exampleone';
Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
From the theme side, that’s all you need to set up Disqus. If you have any issues with comments not loading, make sure you have registered your website with Disqus (Step 1) ↗.
If you still have issues, check the Disqus troubleshooting guide ↗.
Disable Disqus
To disable Disqus comments, open the post.hbs
theme file and comment or delete the line containing the {{> disqus}}
text (line 38
).
Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
Disable Disqus Recommendations
Checkout the Disqus Recommendations ↗ documentation.
If you have any issue with Disqus redirecting to any advertising pages, please disabled Tracking and Affiliate Links from your Disqus account.
Check out Keegan Leary’s blog post about this issue at https://keeganleary.com/disqus-is-evil-trash/ ↗.
Also, be aware of Disqus trackings. Check out https://supunkavinda.blog/disqus ↗.
So, you might want to use another commenting system.
Thanks for sharing, Keegan!
CommentBox
To enable CommentBox ↗ as a comments system, open post.hbs
file and replace line 38
replace with {{> commentbox}}
.
The next step is to create a CommentBox account. From the dashboard, create a new project by filling your site information. You will then receive a Project ID.
Copy that Project ID, open the partials/commentbox.hbs
file, and replace the my-project-id
value with it. That’s it.
Commento
To enable Commento ↗ as a comments system, open the post.hbs
file and replace line 38
with {{> commento}}
.
The next step is to create a Commento account and register your domain ↗ with it.
Show Comments for Signed-in Users Only
If you want to show comments for only signed-in users, open the post.hbs
file and replace line 38
({{> disqus}}
) with the following code.
{{#if @member}}
{{> disqus}}
{{/if}}
You can read more about Ghost visibility choices at Content visibility.
Show Authors
The theme lets you control how and where you show authors.
Sidebar Authors
The sidebar Authors section shows three authors ordered by post count.
To remove this section, open the partials/sidebar.hbs
file and remove line 8
({{> sidebar-authors }}
).
Article Author
The article page will show Author info in two places.
- In the top header, under the title, and near the social sharing icons. To remove, open the
partials/post-header.hbs
file and remove lines25
to33
and lines35
to36
. - Under the blog article content. To remove, open the
post.hbs
file and remove lines23
to25
.
Posts Per Page
You can control how many posts display per page from the package.json
file.
"config": {
"posts_per_page": 8
}
The theme default value is set to 8
posts per page.
Related Posts
If other posts share the same tags, related posts will be visible at the bottom of a post.
Google Analytics
To integrate Google Analytics, I recommend using the Google Analytics ↗ integration by Ghost.
Update Favicon
You can change the favicon in Ghost from Admin > General > PUBLICATION IDENTITY > Publication icon.
Responsive Tables
Responsive tables are required and essential for adding tabular content and allowing tables to be scrolled horizontally. You can make any table responsive across all viewports by wrapping a table
with .responsive-table
, for example:
<div class='responsive-table'>
<table>
...
</table>
</div>
Social Sharing Icons
You can customize and update a post’s social media sharing icons from the partials/share.hbs
theme file.
Sidebar Social Media Icons
Sidebar social media links are placed in the partials/sidebar-social-icons.hbs
file.
Ghost supports adding Facebook and Twitter profile URLs from the admin panel. Go to General > Social accounts and add your URLs. This will update Facebook and Twitter URLs within the footer social media section.
For other social accounts, the theme uses Evil Icons ↗ to provide simple and clean icons. Here you can find a list of the social media icons to use:
<span data-icon='ei-sc-facebook' data-size='s'></span>
GitHub
<span data-icon='ei-sc-github' data-size='s'></span>
<span data-icon='ei-sc-instagram' data-size='s'></span>
<span data-icon='ei-sc-linkedin' data-size='s'></span>
Odnoklassniki
<span data-icon='ei-sc-odnoklassniki' data-size='s'></span>
<span data-icon='ei-sc-pinterest' data-size='s'></span>
Skype
<span data-icon='ei-sc-skype' data-size='s'></span>
SoundCloud
<span data-icon='ei-sc-soundcloud' data-size='s'></span>
Telegram
<span data-icon='ei-sc-telegram' data-size='s'></span>
Tumblr
<span data-icon='ei-sc-tumblr' data-size='s'></span>
<span data-icon='ei-sc-twitter' data-size='s'></span>
Vimeo
<span data-icon='ei-sc-vimeo' data-size='s'></span>
VK
<span data-icon='ei-sc-vk' data-size='s'></span>
Youtube
<span data-icon='ei-sc-youtube' data-size='s'></span>
As mentioned above, Ghosts supports adding only Twitter and Facebook links from the admin. But the theme comes with other social icons in the sidebar. Edit or update these in the partials/sidebar-social-icons.hbs
file. For example, here’s the Instagram code block:
<li class='c-social-icons__item'>
<a href='#' aria-label='Instagram' target='_blank' rel='noopener'>
<span class='c-social-icons__icon' data-icon='ei-sc-instagram' data-size='s'></span>
</a>
</li>
The code above contains the ICON code from the above list and the social media link (a
) within a list element (li
).
Next, replace your Instagram full URL with the link href
value. If your Instagram URL is:
https://www.instagram.com/ghost/
Then the new code will be:
<li class='c-social-icons__item'>
<a href='https://www.instagram.com/ghost/' aria-label='Instagram' target='_blank' rel='noopener'>
<span class='c-social-icons__icon' data-icon='ei-sc-instagram' data-size='s'></span>
</a>
</li>
If you want to remove Instagram altogether, you can delete all the code blocks, the li
, a
, and the icon.
Languages
Krabi comes in many languages already. But if you’d like to add another one, you’ll be able to do that too.
Theme Translation
Krabi supports Ghost i18n ↗ and comes with Arabic, German, Italian, Spanish, French, Finnish, Portuguese Dutch, Turkish, and Danish translations.
To use a language other than English, go to Admin > General > PUBLICATION INFO > Publication Language and enter the ISO Code ↗.
ar
for Arabicda
for Danishde
for Germanyen
for Englishes
for Spanishfi
for Finnishfr
for Frenchit
for Italiannl
for Dutchpt
for Portuguesetr
for Turkish
Add a New Language
To add a new language, follow these steps.
- Create a new file in the theme’s
locales
folder with the language ISO Code ↗ code. So, if the new language is Arabic, the new file name will bear.json
. - Copy the
en.json
file content into your new file and start to translate, as shown in the following section. - Go to Admin > General > PUBLICATION INFO > Publication Language and enter the language code (
ar
in this example).
Edit a Translation
To improve or edit a translation in a specific available language, you can open the language file in the locales
folder:
|____locales
| |____ar.json
| |____da.json
| |____de.json
| |____en.json
| |____es.json
| |____fi.json
| |____fr.json
| |____it.json
| |____nl.json
| |____pt.json
| |____tr.json
For example, the German translation file looks like this:
{
"Loading": "Wird geladen",
"More Posts": "Weitere Artikel",
"Recent Posts": "kürzliche Artikel",
"Featured Posts": "Beliebte Beiträge",
"Page Not Found": "Seite nicht gefunden",
"You might also like": "Das könnte Sie auch interessieren:",
"Latest": "Neueste",
"Authors": "Autoren",
"Navigation": "Navigation",
"Newsletter": "Newsletter",
"Published with {ghostLink} & {themeLink}": "Veröffentlicht mit {ghostLink} & {themeLink}",
"Share on Twitter": "Auf Twitter teilen",
"Share on Facebook": "Auf Facebook teilen",
"Share on LinkedIn": "Auf LinkedIn teilen",
"Share on Pinterest": "Auf Pinterest teilen",
"Share via Email": "Per E-Mail teilen",
"Copy link": "Link kopieren",
"Link copied to clipboard": "Link in die Zwischenablage kopiert",
"Search": "Suche",
"Search {siteTitle}": "Suche {siteTitle}",
"Type to Search": "Suchbegriff(e) eingeben",
"Paid": "Bezahlt",
"Members": "Mitglieder",
"Public": "Öffentlichkeit",
"Account": "Konto",
"Log in": "Einloggen",
"Log out": "Ausloggen",
"Continue": "Fortsetzen",
"Subscribe": "Abonnieren",
"Subscribe Now": "Abonniere jetzt",
"Your email address": "Deine E-Mail-Adresse",
"{siteTitle} Newsletter": "{siteTitle} Newsletter",
"Please check your inbox and click the link to complete the login.": "Bitte überprüfen Sie Ihren Posteingang und klicken Sie auf den Link, um die Anmeldung abzuschließen.",
"Please check your inbox and click the link to confirm your subscription.": "Bitte überprüfen Sie Ihren Posteingang und klicken Sie auf den Link, um Ihr Abonnement zu bestätigen.",
"Please enter a valid email address!": "Bitte geben Sie eine gültige E-Mail-Adresse ein!",
"An error occurred, please try again later.": "Ein Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.",
"Already have an account?": "Hast du schon ein Konto?",
"Don't have an account yet?": "Sie haben noch keinen Account?",
"This post is for paying subscribers only": "Dieser Beitrag ist nur für zahlende Abonnenten",
"This post is for subscribers only": "Dieser Beitrag ist nur für Abonnenten",
"This page is for paying subscribers only": "Diese Seite ist nur für zahlende Abonnenten",
"This page is for subscribers only": "Dieser Seite ist nur für Abonnenten",
"Join the newsletter to receive the latest updates in your inbox.": "Treten Sie dem Newsletter bei, um die neuesten Updates in Ihrem Posteingang zu erhalten",
"Choose your subscription": "Wählen Sie Ihr Abonnement",
"Unlock full access to {siteTitle} and see the entire library of members-only content & updates.": "Schalte den vollen Zugriff auf {siteTitle} frei und sieh dir die gesamte Bibliothek mit Inhalten und Updates nur für Mitglieder an.",
"Subscribe to {siteTitle}": "Anmelden bei {siteTitle}",
"Choose this plan": "Wählen Sie diesen Plan",
"Monthly": "Monatlich",
"Yearly": "Jährlich",
"Free": "Frei",
"Welcome back!": "Willkommen zurück!",
"Log in to your account again.": "Melden Sie sich erneut in Ihrem Konto an.",
"Send login link": "Anmeldelink senden",
"Nice, you're a subscriber!": "Schön, dass Sie Abonnent sind!",
"Your subscription will expire on": "Ihr Abonnement läuft am ab",
"Your plan": "Dein Plan",
"Card": "Karte",
"Expires": "Läuft ab",
"Next bill date": "Nächstes Rechnungsdatum",
"Edit billing info": "ERechnungsinformationen bearbeiten",
"You have an active {siteTitle} account with access to all posts.": "Sie haben ein aktives {siteTitle} Konto mit Zugriff auf alle Posts.",
"You're a subscriber to free members updates": "Sie sind Abonnent der kostenlosen Mitgliederaktualisierungen",
"You are subscribed to free updates from {siteTitle}, but don't have a paid subscription to read all the posts.": "Sie haben kostenlose Updates von {siteTitle} abonniert, haben jedoch kein kostenpflichtiges Abonnement, um alle Beiträge zu lesen."
}
Each line consists of a left key ("More Posts"
) and a right value ("Mehr Artikel"
).
The key is plain English that exists in all translation files and should not be changed. You should change only the value.
If you have any suggestions to improve a current translation or add a new language, please contact me.
RTL
RTL means a right to left. Turning on RTL makes the theme readable for languages written from right to left, like Arabic or Hebrew.
To enable the RTL option, open the partials/head.hbs
file and change line 8
to {{> compiled/inline-css-rtl }}
.
Save the file and upload the theme to your Ghost blog.
Syntax Highlighting
You can add a fenced code block by placing triple backticks ```
before and after the code block. For example:
``` pre { background-color: #f4f4f4; max-width: 100%; overflow: auto; } ```
This will produce the following gray look:
To highlight a code block, add the language alias like css
or js
to the code block. For example, the CSS code in the previous example will wrap between ```css
and ```
as follows:
```css pre { background-color: #f4f4f4; max-width: 100%; overflow: auto; } ```
This will produce the following colored look:
To add inline code, wrap the text between two backticks ` `
.
Prism
Krabi ships with Prism.js ↗, a lightweight, robust, and elegant syntax highlighter.
The initial Prism package ↗ includes some languages, like Markup, CSS, C-like, and JavaScript.
You can add support for more languages. For example, to add support for PHP, get the PHP component script from Prism CDN ↗.
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.13.0/components/prism-php.js"></script>
From the side admin menu, go to Code Injection and add the script to the Site Footer section. Be sure to click Save.
Theme Deploy with GitHub Actions
Krabi comes integrated with the Deploy Ghost Theme ↗ Github action.
I have written about this at How to Deploy Your Ghost Theme Using Github Actions. All you need to do is follow steps 1 and 2.
The Deploy Ghost Theme action is developed by Ghost and works with any Ghost install whether you self-host Ghost or using Ghost Pro.
Code Injection
Another choice for customization is to use the Ghost Code Injection settings in Ghost admin.
For a CSS example, you can use the following code in the Site Header section to change the logo color and font size.
<style>
.c-logo__link {
color: #4550E5;
font-size: 32px;
}
</style>
Watch the following short video about Ghost Code Injection, how it works, and how to use it.
Changing Colors with CSS Variables
Using Code Injection, you can change the theme colors with CSS Variables.
For the list of available theme color variables, check out the assets/sass/settings/colors.scss
theme file. It will look like this:
:root {
--color-brand: #5869DA;
--color-white: #FFFFFF;
--color-dark: #000C2D;
--color-text: #000C2D;
--color-gray: #687385;
--color-error: #CC3C64;
--color-success: #07815C;
--color-border: #EAECEE;
--bg-gray: #F5F7F9;
--bg-gray-darker: #EDEFF1;
--bg-dark: #12245A;
--bg-white: var(--color-white);
--color-code-inline: var(--color-text);
--bg-tag-list: linear-gradient(to left, var(--bg-white), rgba(255, 255, 255, 0));
}
For example, if you wanted to change the theme’s brand color, you’d change #5869DA
in this case. You can copy the color variable to Code Injection > Site Header and assign it your new color, as in the following example.
<style>
:root {
--color-brand: red;
}
</style>
The result will look like this:
The variable --color-brand
is used for buttons, links, and link hovers. In the above example, we changed the color to be red
. You can override this for any other variable.
If, for example, you want to add a color that’s not in the available theme variables or add another style to a new element, you can create a new variable and give it a name and value.
We can extend the previous example to add a new color for the logo color and assign that variable to the .c-logo__link
class.
<style>
:root {
--color-brand: red;
--color-logo: blue;
}
.c-logo__link {
color: var(--color-logo);
}
</style>
The logo will then have a blue
color.
Customize Image Height
If you want to customize the height of the images on the home page or the article page, you can use the following CSS code.
For a single post image, the theme default value is 56.25%
. You can change this value to match your preference.
.c-post-image-wrap:after {
padding-bottom: 56.25%;
}
For the homepage cards, the theme default value is also 56.25%
.
.c-post-card__image-wrap {
padding-top: 56.25%;
}
The full code in Code Injection would be:
<style>
.c-post-image-wrap:after {
padding-bottom: 56.25%;
}
.c-post-card__image-wrap {
padding-top: 56.25%;
}
</style>
Customize Logo Size
If you are using an image as a logo (instead of the site name) and want to change the logo size, use the following code in Code Injection.
<style>
.c-logo__img {
max-height: 32px;
}
</style>
The default value is 32px
, so you can increase this value to match your preference.
If the logo image has a large white space around it, trim that space with a photo editing app for better results.
Changing Colors with CSS Variables
Using Code Injection, you can change the theme colors with CSS Variables.
For the list of available theme color variables, check out the assets/sass/settings/colors.scss
theme file. It will look like this:
:root {
--color-brand: #5869DA;
--color-white: #FFFFFF;
--color-dark: #000C2D;
--color-text: #000C2D;
--color-gray: #687385;
--color-error: #CC3C64;
--color-success: #07815C;
--color-border: #EAECEE;
--bg-gray: #F5F7F9;
--bg-gray-darker: #EDEFF1;
--bg-dark: #12245A;
--bg-white: var(--color-white);
--color-code-inline: var(--color-text);
--bg-tag-list: linear-gradient(to left, var(--bg-white), rgba(255, 255, 255, 0));
}
For example, if you wanted to change the theme’s brand color, you’d change #5869DA
in this case. You can copy the color variable to Code Injection > Site Header and assign it your new color, as in the following example.
<style>
:root {
--color-brand: red;
}
</style>
The result will look like this:
The variable --color-brand
is used for buttons, links, and link hovers. In the above example, we changed the color to be red
. You can override this for any other variable.
If, for example, you want to add a color that’s not in the available theme variables or add another style to a new element, you can create a new variable and give it a name and value.
We can extend the previous example to add a new color for the logo color and assign that variable to the .c-logo__link
class.
<style>
:root {
--color-brand: red;
--color-logo: blue;
}
.c-logo__link {
color: var(--color-logo);
}
</style>
The logo will then have a blue
color.
Center Post Page

To center the blog post content and remove the sidebar, follow these steps.
- Duplicate the
default.hbs
file and give it another name, for example,default-post.hbs
. Then, remove lines17
to19
. - In the
post.hbs
file, change the first line to{{!< default-post}}
.
That’s all that you need to do. The post will be centered automatically.
If you want to center the individual pages too, in step number 2 edit the page.hbs
. Change the first line to {{!< default-post}}
.
In case you want to add a wide and full-width style to images, you can add the following CSS code to the Code Injection (Site Header) section.
<style>
.kg-width-full {
width: auto;
}
@media (min-width: 40em) {
.kg-width-full .kg-image {
max-width: 100vw;
pointer-events: none;
}
}
@media (min-width: 64em) {
.kg-width-wide {
width: 100vw;
max-width: 1140px;
padding-left: 40px;
padding-right: 40px;
}}
</style>
Add Custom Homepage
Follow the next steps to add a custom homepage to your website instead of showing the recent blog posts.
You can also Watch the following video.
Create the home.hbs File
In the root of your Krabi theme, create a new file, and name it home.hbs
.
Next, copy the following code to it.
{{!< default}}
{{#page}}
<article class='c-{{ post_class }}'>
{{> post-header }}
<section class='c-content'>
{{ content }}
<br>
</section>
</article>
{{/page}}
Once you finish, zip the theme files, and upload the final zip file to Ghost.
Update and Upload the Routes File
Copy the following code to the theme routes.yaml
file and then upload it.
routes:
/subscribe/: members/subscribe
/signup/: members/signup
/signin/: members/signin
/account/: members/account
/:
data: page.home
template: home
collections:
/blog/:
permalink: /blog/{slug}/
template: index
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
That’s all for this step.
To know what’s going on in the above code, we tell Ghost to do the following:
- Use the home template file for the homepage instead of the index file.
/:
data: page.home
template: home
- Using collections, make the posts available at the
/blog/
URL and use the index template file.
collections:
/blog/:
permalink: /blog/{slug}/
template: index
Create the Homepage
In Ghost admin, create a custom homepage as a Ghost Page.
Make sure that the Page URL setting is home
.
Add your content and publish the page.
Now, go to your website homepage, and you should see the homepage becomes the static page you created like the following examples.
Like the regular theme page view, upload a page feature image, and it will be visible first.
Or skip it and the title will come first.
Add the Blog Item to the Navigation
After moving the posts to the /blog/
URL you may be asking: How can I access this URL without typing it in the browser bar?
You can add it as a Navigation item.
One more thing you might want to change is removing the Latest tab item in the header tags bar. It is no longer describes the destination page, which is the homepage with the latest posts by default. It is now a custom page.
Change RSS Icon URL
Becuause we moved the posts to the /blog/
URL, the website RSS feed will now be accessed throght /blog/rss
instead of /rss
. So, we need to change the URL in the sidebar RSS icon. To do this, open the the partials/sidebar-social-icons.hbs
theme file and change the URL for the RSS link from /rss
to /blog/rss
.
404: Page Not Found
In case you get the 404 message on the homepage, do the following:
Go to Design > Installed Themes section in your Ghost admin.
Then, activate another theme other than Krabi and activate Krabi again.
This should solve the issue.
Show Full Post Content Instead of an Excerpt on the Homepage
Open the partials/post-card.hbs
file and replace line 32
with the following line.
<div class='c-content u-mt-16'>{{ content }}</div>
Remove Date from All Posts
To remove the date from all posts, add the following CSS code to Ghost Code Injection.
<style>
.c-teaser__date,
.c-post-card__date,
.c-post-header__date,
.c-search-result__date {
display: none;
}
</style>
Click Save.
This code will remove the date from the following:
- Sidebar postcard
- Home postcard
- Post page
- Search results
Add a New Sidebar Widget
If you want to add a new widget to the sidebar, use the following code as a widget’s skeleton.
To add it to the sidebar, copy and paste it in the /partials/sidebar.hbs
theme file before line 9.
<div class='c-widget'>
<div class='c-title-bar'>
<h3 class='c-title-bar__title'>YOUR_TITLE</h3>
</div>
<div class='u-bg-white u-border u-border-radius u-p-32'>
YOUR_CONTENT_HERE
</div>
</div>
Here you have two content placeholders.
- YOUR_TITLE: Replace this with your widget title
- YOUR_CONTENT_HERE: Replace this with your widget content
If you don’t want to add a title, your skeleton looks like this:
<div class='c-widget'>
<div class='u-bg-white u-border u-border-radius u-p-32'>
YOUR_CONTENT_HERE
</div>
</div>
Change Subscribe Box Background Icon
You can add your SVG icon to the theme /assets
directory, then with CSS in Ghost Code Injection, add it as background as follow:
<style>
.c-subscribe {
background-image: url('/assets/icon.svg');
}
</style>
This will override the current icon. You might also need to configure the background-position
to match your icon size.
Remove Subscribe Box at the Bottom of a Post
To remove the subscribe form at the bottom of the post, open the theme post.hbs
file and remove lines from 28
to 38
.
Fixed Header
To make the header fixed on scroll, use the following CSS code in Ghost Code Injection.
<style>
body {
margin-top: 72px;
}
.c-header {
position: fixed;
top: 0;
z-index: 3;
width: 100%
}
</style>
To make the header fixed only on large screens, use the following code instead.
<style>
@media (min-width: 64em) {
body {
margin-top: 72px;
}
.c-header {
position: fixed;
top: 0;
z-index: 3;
width: 100%
}
}
</style>
You will probably need to increase the body margin-top to be more than 72px
if you increased the Logo Size.
The result will look like this:
This will make the header fixed but not the tags menu.
Add Table of Content
To add a simple Table of Content (TOC) section on top of the article. Follow the following few steps.
1) Add the following code in Ghost admin Code Injection (Site Footer).
<script src='https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.2/tocbot.js'></script>
<script>
tocbot.init({
tocSelector: '.toc',
contentSelector: '.c-content',
hasInnerContainers: true
});
</script>
2) Open the post.hbs
file and add the following before the {{ content }}
line.
<div class='toc'></div>
The result will be like this.
If you are using a Fixed Header, use the following code in Ghost admin Code Injection (Site Header) to fix the headings being hidden by the menu when you click any of the Table of Content links. Thanks Yeray!
Note that the scroll-margin-top
CSS property has limited support on mobile, so it might not work. I would suggest making the header fixed only on large screens.
<style>
.c-content h1,
.c-content h2,
.c-content h3,
.c-content h4 { scroll-margin-top: 72px; }
</style>
You may want to adjust the 72px
value, but it should work fine.
Open Post Links in a New Tab
To open the post links in a new tab, add the following script in the Code Injection Site Footer section.
<script>
document.querySelectorAll('.c-post a').forEach(function (e) {
if (e.hostname !== window.location.hostname) {
e.target = '_blank';
}
});
</script>
Thanks Taylor.N for sharing this snippet!
Change Blockquote Style
If you think the blockquote style is a bit large, you can customize it with CSS. Use the following CSS code in Ghost Code Injection to make the font the same size as the content text.
<style>
blockquote {
font-size: 18px;
line-height: 28px;
box-shadow: 0 0 black;
border-top: 0;
border-left: 2px solid var(--color-brand);
padding: 0;
padding-left: 16px;
}
</style>
The code will also remove the top and bottom border. Instead, it will add a left border.
The blockquote new style will be:
Feel free to change the code to match your style.
Homepage Two Column Posts
To convert the homepage to two columns posts layout, use the following CSS code in Ghost Code Injection Site Header section.
<style>
@media (min-width: 40em) {
.js-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-column-gap: 40px;
}
.c-post-card__content {
display: flex;
flex-direction: column;
}
.c-post-card__title {
font-size: 20px;
line-height: 24px;
}
.c-post-card__excerpt {
margin-bottom: 16px;
}
.c-post-card__meta {
margin-top: auto;
}
}
</style>
The result will be.
This will be applied only to medium and large screens, but the mobile layout will be the same. The layout is not recommended for small screens due to the limited space.
If you want to apply this to mobile too, you can remove the second line starting with @media
and the line before the end, the }
.
Changing Theme Font
Krabi is using one font, Inter.
The theme loads Inter using Google Fonts in the theme partials/fonts.hbs
file. It is then assigned it to the body
element along with other system fonts as a backup as the following example.
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
}
To change to any other font, you need to include the font on your theme or using Code Injection Site Header if you are using Google Fonts, for example.
For example, if you want to use the Roboto font from Google Fonts. Your code in Code Injection might be like this.
<link href='https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap' rel='stylesheet'>
<style>
body {
font-family: 'Roboto', sans-serif;
}
</style>
You need to change that to the buttons and input elements.
<style>
.c-btn,
input {
font-family: 'Roboto', sans-serif;
}
</style>
You might find the following posts useful as well:
- How to Change a Ghost Theme Font Using Google Fonts
- How to Change the Fonts of the Casper Ghost CMS Theme Using Google Fonts
Loading Custom Font
I assume that you have the font files and the initial @font-face
CSS code for loading the font. Something similar to the following code.
@font-face {
font-family: 'Atyp';
src: local('Atyp Text Regular'), local('Atyp-Text-Regular'),
url('AtypText-Regular.woff2') format('woff2'),
url('AtypText-Regular.woff') format('woff'),
url('AtypText-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
}
➊ Create a new folder in the theme under /assets
and name it fonts
, for example, then copy your font files there.
➋ Once you finish, zip the theme files, and upload the final zip file to your Ghost website.
➌ In Ghost admin Code Injection, add your @font-face
code with the new font files path wrapped in the <style>
element.
<style>
@font-face {
font-family: 'Atyp';
src: local('/assets/fonts/Atyp Text Regular'), local('Atyp-Text-Regular'),
url('/assets/fonts/AtypText-Regular.woff2') format('woff2'),
url('/assets/fonts/AtypText-Regular.woff') format('woff'),
url('/assets/fonts/AtypText-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
}
</style>
This should load the fonts. Then you can use the font and do your styling for the body and so on.
Theme Development
If you are a developer and need to do heavy customization work, the theme uses Gulp ↗ to compile Sass ↗ and JavaScript. This improves the development flow and makes it much faster.
Note
Changing any hbs
file, for example, the post.hbs
file does not require being in development mode with gulp running. Just edit the file in your preferred editor and upload it.
First, make sure you have Node.js ↗, npm ↗, Gulp CLI ↗, and Bower ↗ installed. Check My Current Setup.
Run the following command in the theme root directory to install npm and bower dependencies.
npm install
To start Gulp, run:
gulp
This will compile Sass and JavaScript files and start watching changes as you edit files.
Gulp will produce two files:
➊ assets/js/app.min.js
: The final main JavaScript file.
This file is generated from many other JavaScript files listed in the gulpfile.js
file. Gulp will do all the work to create that file, so no manual work is needed.
Gulp will watch your changes in the assets/js/app.js
or assets/js/ghosthunter.js
(if exist) and will then generate the final app.min.js
file.
➋ partials/compiled/inline-css.hbs
: The final CSS file.
This file is generated from the assets/css/style-min.css
file, which was generated by Gulp. It is used as an Internal CSS in the theme partials/head.hbs
.
If you are working with Gulp, it’s recommended you avoid editing these files. Instead, do customizations in assets/sass
for CSS or in assets/js/app.js
JavaScript. This way, you can make sure the flow is going in the right direction and never lose any changes.
My Current Setup
In case you are wondering what my current environment set up is and which package versions I use, take a look at the following:
$ node -v
v10.16.0
$ npm -v
6.14.8
$ bower -v
1.8.8
$ gulp -v
CLI version: 2.2.0
Local version: 4.0.2
This environment works well for running Ghost and also for theme development.
I use macOS Big Sur.
Zip Theme Files
To create a zip file after your theme changes, you can use one of the following options.
Use one of the first two options if you are on a Theme Development mode.
Using the command line
zip -r krabi.zip krabi -x '*node_modules*' '*bower_components*'
This will exclude the node_modules and bower_components directories from the final zip file.
Using Gulp
If you are running gulp, you can type the gulp zip
command to do this.
Using your computer program
You can compress it as a standard folder just like you do with any other folder on your computer. If you are on Mac, right-click on it to view the context menu. Then, click the “Compress” option.
Theme Update
You may be wondering: how can I update my theme to the latest theme version?
There are two choices:
- Keep your current theme and replace only the changed files from the new version. You can find the modified files on the theme page Changelog
- Use the latest version as a starting point and redo your theme changes and customizations
One way to reduce the need for redoing customizations is to use the Code Injection tool. This is very helpful for adding custom CSS and tracking code. Keeping your custom CSS code with Code Injection is always recommended.
Your feedback is very welcome ♥
I'm open to your feedback and to hear about your experience. If you have about one minute, please send your thoughts through this Google Form ↗.
Thank you for your time!