I followed the instructions in the grav documentation on how to customize your own theme using theme inheritance. However, I can’t seem to figure out how to change the header on my website, which currently just has the Afterburner 2.0 logo. I would like to change this to my own logo.
A more general question as well - I expected things such as the header and footer to be customizable from the Grav Admin webpage. Is this the case and I was just being silly, or in general if you want to customize anything about your theme you need to get down and dirty with Twig? If the latter, does anyone have a better tactic than just searching through all the afterburner theme files and Ctrl+F ing until you find what you want to edit?
@gobs, Some themes (not Afterburner2 though) have a build in property that points to the logo file.
This property is then exposed in the Admin panel. When using theme Quark it will look as follows:
Yes. it may seem a burden to search through the files, but Grav is quite structured and themes and plugins follow that same structure. That makes them all quite similar. You will soon know where ‘stuff’ happens.
Ok, how to change the logo in Afterburner2?
If you open the developer tools of the browser, you will see that the logo is defined in ‘_header.scss’ with the following css:
Because ‘custom.css’ resides in your theme, the url ‘…/images/logo.png’ will now point to the logo inside your theme.
Add your own logo.png to folder ‘user/themes/mytheme/images/’
The ‘custom.css file’ needs to be added to the page. Stylesheets are mostly added to a page by template ‘base.html.twig’. In your case, that will be ‘user/themes/afterburner2/templates/partials/base.html.twig’.
Copy that template into the ‘templates/partials’ folder of your own theme.
To add ‘custom.css’ to the page, add the following line to line 18:
scss:
In scss you can define variables ( $logo-image ) and reuse them at other places. In file ‘/user/themes/afterburner2/scss/configuration/template/_colors.scss’, the variable $logo-images is defined as:
$logo-image: url(../images/logo.png);
Size of logo:
When using a background image, by default, the element only shows the part of the image that fits the size of the element. The size of the anchor (<a>) is set to 255x50px. You logo has a size of 2028x1552px…
Options:
First, you should resize the logo using any image editor (e.g. Gimp) to the size you want your logo to display. Your users will be happy because that saves them a lot of bandwidth…
You could fiddle with the css properties of the background image to make the logo scale to fit the size given to the <a>.