How to put all sections and articles on home page
Please follow this short tutorial about how to put all sections and articles on the home page of your Help Center (according to thispost). There are few ways to achieve that, but I will explain one of them, probably the most easiest.
Example:https://support.twilio.com/hc/en-us
So:
Put all the content (all sections) in just one category (how to do that)
- Go to editor for design changes (General / Customize design / Home page)
- Find code row provided under, and remove it and whole code in this section (if you can't find it, just skip this step):
- Put here this code
{{#if categories}}
{{#each categories}}
{{#if ../has_multiple_categories}}{{name}}
{{/if}}
{{#each sections}}
{{#if internal}}
{{/if}}
{{name}}
{{#if articles}}
{{#if promoted}}
★
{{/if}}
{{title}}
{{#each articles}}
{{/each}}
{{#if more_articles}}
{{t 'show_all_articles' count=article_count}}
{{/if}}
{{else}}
{{t 'empty'}}
{{/if}}
{{else}}
{{t 'empty'}}
{{/each}}
{{#if more_sections}}
{{/if}}
{{/each}}
{{pagination}}
{{/if}} - Save and Publish changes. You should get your sections and articles on the home page of your Help Center.
Hope this helps, if not, feel free to put a comment under!
-
Thank for posting this, Vladan. This is a great help for those who wants to have this on their homepage. Really easy to follow, too. Thumbs up!
-
Awesome tip, Vladan. Thanks for sharing!
-
Thank you very much for this snippet. May I ask you how you would split the content into two columns?
Thanks a lot,
-
A big thanks to you, Vladan! I've been trying to do this and learn HTML5 at the same time by looking things up on the web. Should have known to start with Zendesk Support articles first, you guys are great!
-
Hey there, also wondering how to split the content into two columns? Thanks!
-
Hi Matthew, Welcome to the Community!
Just to check are you on Copenhagen theme? Could you share a screenshot of what you got there?
-
Is there a way to split it into 2 columns?
-
Hi Edul! Yes, that is possible.
Open CSS file of your Help Center theme (Guide admin / Themes / Select active theme / Edit code),
and find this value (should be the 812th line in this ZD default Copenhagen theme):flex:1 0 340px;
Just make a little change so it looks on this way:
flex: 1 0 420px;
That should be all. If it doesn't work, please provide me here with a link to your help center.
Thanks! -
Hi Vladan - Thanks for the info!
Do you happen to know a way to have the "View all XX articles" expand on the homepage, rather than click thru to the category page?
Thanks in advance!
-
Hi Caroline, Yes that is doable and requires much more coding.
If you have a front-end developer in your team just direct him to the Zendesk API documentation, a part which applies to the listing of all articles within a section:https://developer.亚博zendesk。com/rest_api/docs/help_center/articles#list-articles
Hope this helps.
-
Thanks Vladan! Will give this a try.
-
Thanks for sharing this Vladan! One minor detail: I had to wrap {{#each sections}} with
to get everything working perfectly. It fixed a bunch of margins and made the whole thing show up with two columns without even tweaking the CSS code.
{{#each sections}}
[...] code removed for readability [...]
{{/each}}Thanks for the update, Guillaume!
[SOLVED]
Hello, I am doing some fetch from the API to get all categories and sections, but I have some sections that are private. Is there a way to filter does private categories/sections on the API?
https://developer.亚博zendesk。com/rest_api/docs/help_center/sectionsHave you tried looking at theuser_segment_idattribute?
Hello i followed all the tips mentioned even in the comments. The section appeared as columns however there's no margin on the left column
Can you please share the URL of your HC where you implemented this so that I can go through it and provide you the exact solution to your problem.
Thanks
Pulkit
TeamDiziana
Hey Kathrina,
You can try this.
Paste this code on home page:
{{#if categories}}
{{#each categories}}
{{#if ../has_multiple_categories}}{{name}}
{{/if}}
{{#each sections}}
{{name}}
{{#if articles}}
{{#if promoted}}
★
{{/if}}
{{title}}
{{#each articles}}
{{/each}}
{{#if more_articles}}
{{t 'show_all_articles' count=article_count}}
{{/if}}
{{else}}
{{t 'empty'}}
{{/if}}
{{else}}
{{t 'empty'}}
{{/each}}
{{#if more_sections}}
{{/if}}
{{/each}}
{{pagination}}
{{/if}}Paste this CSS code on your stylesheet at the bottom side:
.container{
max-width:1160px;/ /容器容器宽度取决于你的主题, may your container width if 1100px , 1400px etc.
}
.section-wrapper{
display:flex;
flex-direction:row;// It could be flex-direction:column - depends on you
}
.section-wrapper .section{
flex: 1 0 100%;// On mobile devices
}
@media (max-width:1024px){
.section-wrapper .section{
flex: 1 0 340px// On Desktop
margin-right:30px;
}
}And
Here is section class so if you need to add margin in section columns, you can add like this:
.section{
margin-left:30px; //As per your requirement
}
OR
.section{
margin-right:30px; //As per your requirement
}Thanks
Hi there. This no longer works "out of the box" for Copenhagen theme 2.8. Has anyone updated theirs to work with the new theme? Thanks!
Hi there,
I'm facing this problem with the article count in the category section. I tried the above with not luck.
There are 9 articles when I click on the category FAQBut on 6 show up and in the wrong order.
Can you please help me rectify this where I can show all articles on the home page since we only have 9 at the moment, and list them correctly?
Many thanks,
Rick
Is there anyway I could filter out articles tagged with a specific label instead of showing promoted articles. Thanks in advance,
Hi Shweta, with the native functionality it is not possible to filter by article labels and present only those articles.
Pleasesign into leave a comment.
22 Comments