# Making custom changes to the sidebar programmatically

**URL:** <https://meta.discourse.org/t/making-custom-changes-to-the-sidebar-programmatically/273027>\
**Category:** Development\
**Tags:** rest-api, sidebar\
**Created:** [July 27, 2023, 9:14am UTC](https://meta.discourse.org/t/making-custom-changes-to-the-sidebar-programmatically/273027 "2023-07-27T09:14:04Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![literarymachine](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@literarymachine](https://meta.discourse.org/u/literarymachine)\
**Post date:** [July 28, 2023, 5:47pm UTC](https://meta.discourse.org/t/making-custom-changes-to-the-sidebar-programmatically/273027/5 "2023-07-28T17:47:00Z")

</div>

> [@awesomerobot](#):
>
> I think the indenting can probably be handled with styling in CSS?

Having looked into it a bit further, I am confident that this will work, yes! My challenge now is that the list of links is dynamic and can potentially change with each page change. My naive approach of calling `api.addSidebarSection` from within `api.onPageChange` does not work because (a) the sidebar is only refreshed when it is re-rendered by hiding and showing it again and (b) the sections are repeated because `api.addSidebarSection` does not care if the name key is reused.

Any chance I can achieve a sidebar section that is updated on each page transition with the new API?

---

_[View the full topic](https://meta.discourse.org/t/making-custom-changes-to-the-sidebar-programmatically/273027)._
