Is it safe to delete header.html from child theme? Duplicated from parent theme.

Hi,

During development, we made a copy of the header.html file from the parent theme and moved it to the child theme. We forgot about it and it’s been there for quite some time now, unchanged, and meanwhile the header.html in the parent theme has been updated a few times. So the active header is out of date and has some minor issues.

What we want to do is to remove the old header.html file from the child theme, so that the system reverts back to the up-to-date header.html in the parent theme.

Since the theme folder structure is the exact same, and the location and name of the file is the same between the parent and child theme, I would assume deleting the file should do the trick.

But the header.html file in the child theme i used by most pages on the live website, so I wanted to check if anyone has any best practices or suggests to share? Wouldn’t want to break anything. :slightly_smiling_face:

@JTapper so I’ve run into this a time or two and the header.html is most likely a partial file that holds the configuration for the header settings, so even though it holds the same code and you didn’t make changes to it, if you delete the file from the child theme and revert to the parent file and default settings. You’ll most likely have to rebuild your header via the global content editor (or whereever your header settings are configured) - the exception is if your header is fully configured in theme settings.

One option would be to copy the code from the parent/marketplace and replace the code within the child theme file, this should keep everything compatible without losing any settings - and if you do, it’s easy to revert.

The other option would be to remove it (after hours) and prepare to rebuild your header - I would open all header settings and document how it is all configured so that rebuilding is easier to do.

It is very dependent on how the theme is configured, hope this helps!

@Jnix284

Yes, it’s a global partial that is mainly configured in the global content editor. Some of the settings are in the theme settings as well, such as menu aligment, colors and fonts.

It’s fetched in a base.html layout file with {% global_partial path=“../partials/header.html” %} (the theme is based on the cms boilerplate).

Alright, so the header settings would be reset - good to know, thanks! I think I’ll start by just copying over the code from the file in the parent theme as you suggested. As long as the theme isn’t updated too often, that could be a decent solution.

We also have a copy of the base.html file in the child theme, which is still up to date - the origininal in the parent theme is pretty much the same as the one in the cms boilerplate. So no rush to fix that one, but I suppose the solution would be the same?

@JTapper ok cool - yep, yours is configured the same as the ones I worked with. The dev I was working with at the time didn’t know why it reset the settings, since it was the partial and not the module where they were being set.

base.html is kind of the same, it rarely changes in a marketplace theme but there are some tricks you can do to optimize your child theme (like prioritizing your child.css) and the key is really that all of your templates will run off of the base file, that’s how it knows to include the header, footer, etc.

Another option, depending on how many files you customized in the child theme would be SpaceRockX - one of the devs I used to work with developed a way to update your child theme files to the latest marketplace version automatically, accounting for your custom code changes so you don’t lose the customization or new features. He’s pretty brilliant with themes, I’m not sure exactly how it works, but I’ve used it and it saves a lot of time.

Hi, i also faced the same issue as yours, may i know if you have any update about the soultion that you did which is by just copying over the code from the header file in the parent theme to the header file in the child theme
Is this solution works for you?

Hi @JTapper

I don’t think it should cause any issue but make sure which header is being used in your base template. If its the child theme’s header then you will have to update it and then you can remove it.

“I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!”

@GRajput This is not true, nor is it how the child theme relationship for the header works.

Hi @JTapper,

I’d be very careful with deleting something. Especially if it has been some time since you (or somebody worked in the theme).

My recommendation before deleting a file from a child theme is always: make sure it’s not used anywhere.

You can check the dependencies of a file by opening it in the design-manager and navigate to

Actions → Show dependents.

best,

Anton

@Anton good call out on the dependents, however since it’s a header file in the child theme, it will either show one of two things:

1 - that all the files are dependent on it

2 - that none are

neither of these would indicate what is actually happening with the file or how the header is configured in the theme for the live site.