Category Banners uses existing category details to create banners for your category pages. It uses the category name, description, and color to generate a banner at the top of the relevant category pages (for tags check out Discourse Tag Banners).
The category description is defined by the first paragraph in each categoryās āCategory definition for ā¦ā topic. The banner background/text colors are defined by your category badge settings.
By default, this will display on desktop and mobile across all Category and Subcategory pages but will not appear if you havenāt given your category a description.
Settings
This component comes with options to override the defaults:
Name
Description
show description
Show description from āAbout This Categoryā post
When the category icons are used, enabling this will make the icon match the banner text color
Customization notes
If you want to customize these with some additional CSS you can target specific category headers by using this structure (example-category is your category name):
thanks for this wonderful theme , it helps users to note the category description much easier.
currently if thereās a link or a bold/italic word in the category description, in the banner itāll appear as simple text (e.x. p style instead of a style). isnāt it better if the text style is preserved in the banner as well?
Hi, I absolutely love this component! Thanks for your work!
Iām wondering, how can I style the background so that it automatically pulls the category background image and makes it the background of the banner. The backgrounds are already hidden anyways, so I want it to simply display as the background to the banner, rather than the page. Iāve tried this, but it didnāt work and I think I might be targeting the wrong variable:
Not prefixing the category name is a recipe for disaster, so Iāve added category-banner- before the class name (e.g., category-banner-meta). If you were targeting the category name in your CSS youāll just have to add category-banner- before it.
Iām not sure, I donāt think our default category descriptions support them either, but I can look into itā¦
I want to use the uploaded background image from the category to put it in the background of the banner. Iāve edited the code and everything looks great. I wonder is there anything I can do to make the image load faster or together with the rest of the page? I want to avoid the flickering of the background for a second before the image appears.
Compressing image is certainly an option, but I wonder if there are others. Can I grab the thumbnail of the uploaded background image in the code? Thanks for all leads!
I just tried installing it, following this tutorial (did exactly the same steps) to try this Category Banners component, but nothing happens. No banner in any of the categories. Is there anything that I might have done that doesnāt make it work? The only explanation I see is that the ābootstrapā warning blocks it?
By default, the theme component does not display category banners if you have not set a category description for a category. This can be changed by unchecking the āHide banners if category description not setā checkbox.
Category descriptions are set by editing the About category topic that Discourse automatically creates for every category. If you have either added category descriptions, or disabled the setting to hide banners for categories without descriptions, and you are still not seeing category banners, let us know. Weāll look into what is going on.
Thank you for your answer. I have checked and confirm that each category on the forum has a description. The āHide bannersā¦ā option is now unchecked just to make sure but nothing changes.
As you can see on the images, everything looks normal in the settings :
Is there anyone other than me that thinks it would be nice to enable this same styling on Group listing pages (e.g. /g/foo) as well? The CSS, unfortunately, is not quite the same, and I guess it would require some additional handling of the various buttons to the right side of the group name, i.e., Request Message Delete
It could go a long way for a consistent look and feel, and make groups feel more like a āfirst classā citizen among the UI. (IMHO)
It pretty much does the same thing but with some modifications:
The category banner box is displayed in-line above the main heading instead of full width at the top. This allows for display a banner theme at the top, for example the discourse-versatile-banner.
The category banner box is displayed in the same style as the native discourse subcategory boxes, which are a core component of discourse. These subcategory boxes are a display option in the discourse category settings Show subcategory list above topics in this category . This option displays the subcategory category name and description as a row or box above the topic list, using the category background colour as the left border.
If the category is a subcategory, the category name is displayed as breadcrumb as follows - Parent category name: Subcategory name
Demo screen shot of theme banner box for the category, above the native subcategory boxes.
This is my first attempt at a theme modification. I hope this is helpful?
Update
I have refactored this adaption as a separate component - with many additional features including using the category logo image and background image in the header. This new component effectively replaces the standard Discourse category header, unlike the category banners, hence making it a new component. Please see:
This isnāt working for us. Iāve tried both the category slug and the category ID, but the banner stays stubbornly there. Is this working for anyone else?
I just tried it and it works for me, itās looking for the case-sensitive category name. In retrospect that was not the best way to implement itā¦ I can probably improve that.
Ah - that sort is for me! And you do state ānameā in the guide above - I just didnāt read that.
Name isnāt very intuitive as we donāt really use it for anything else. But it is displayed a lot. Just making it more explicit in the settings would be fine I reckon.
Instead of adding exceptions of what which categories will not show a given uploaded banner, canāt we just specify which category should show which banner?
Depends on the specific site and use-case Iām sure. My initial thought was that it would be more likely for a site to want it implemented everywhere, and if there were exceptions it would only be a few.
If you wanted to implement a banner for a small number of categories there might be a better theme component option thatās built to be a less generic cover-all, like Versatile Banner or customizing one of the options found in Banner themes (and instructions for customizing them)
Add the restricted class to the <span.discourse-category-banners> or <div.category-title-header> element when the category is not public, the same way the category badge has.
It would be useful for tweaking the banner with an additional CSS to show the user that this category is special.
Right now, it is doable but complicated to select with CSS the lock icon and do some stuff, but since CSS doesnāt have parent selector, I can not use the presence of the lock icon to check if the banner should be modified.
I donāt really know how to do PRs yet, but would use this as a good reason to learn if youād be up for my modification.