Editing a component (sidebar) to display on every page

Hi there,

I’m trying to figure out how to integrate a sidebar in my application for a while now. What I’m looking for is a way to edit a sidebar in the Netlify editor once and have it displayed on every page without having to fill in the same content in every markdown file. Currently I’m adding the desired content for the sidebar in one file which works fine, however I obviously can’t use it in another file thus it is not rendered on other pages.

An idea I had was to create the same fields for customizing the sidebar content in other files, referencing them to those in the first file and hiding it in the editor so the user can’t change it. If I’m not wrong I can’t do it this way as it isn’t possible to automatically populate a referenced field with the value of another file.

I’m using NetlifyCMS together with GatsbyJS and source page data from markdown files, if this is of importance.

I literally already spent hours on this but just can’t seem to figure anything out. Any input is appreciated!

Thanks,

Jenny

Hi @gloomicious, usually for sharing content over pages in your site, you would use a file collection to store the settings/content in a file:


Then in Gatsby you’d have a Sidebar which is a part of the pages layout and sources the information from the settings file.

Hopefully that makes sense. If not please share a repo with some attempts you’ve made. That should make it easier to find a solution.

That’s a perfect solution - thank you very much! I didn’t expect it to be so easy. Definitely learned a lot from this one.

1 Like