Manipulating layout elements with JavaScript

I’m trying to use JavaScript to manipulate elements in a layout from a page that uses this layout. Rather than applying this script to JUST this page as I expected, it applied to ALL pages that use this layout. I’m using jekyll-paginate-v2 and this page is a pagination page. I know this could be a potential cause, but I’m not sure why this happened.

I’m adding this exhibition as some say this question is unclear. I have a layout layout1.html. Multiple pages,, and, etc. all use this layout.

For I wanted to change certain elements in layout1.html a bit. This means this change should take place in the layout ONLY when it is applied to So the JavaScript is a simple document.getElementById code inside but not in the layout or other pages.

The output, rather than changing layout1.html elements only when it’s used by, this code somehow applied this change to the layout across other pages (,, etc.) that use this layout as well, which is the problem.

can you be more specific? not really sure what you are saying.

Though if you have JS that is changing something in a layout how would it know to only work on one page? is the JS in the layout? if so I would expect that I think.

@rdyar Apologies for the confusion, but I’ve answered it in the first sentence. This script is located on a page that uses the layout which the script tries to manipulate. Rather than taking effect on just this page, this has changed the layout for all other pages using the layout.

do you have links to the repo and a live site where we can see it?

my guess would be some sort of caching issue but not sure. If you visit page3 in a different browser does it do it? just directly going to that page and not any others.

As the website uses plugins that GitHub Pages doesn’t support, I’m only pushing the _site folder to the repo. The site is big in size with many post pages.

My guess is that Jekyll-Paginate-V2, the plug-in for paginating the site, is the source of the issue as it acknowledges in its own documentation there were cases in which developers reported to have encountered this page overwriting issue.

If you need to take a look at the site, I’ll need to convert it into a template, upload Jekyll files to a repo, share the link here, and you will need to download and run it to see the output.