ʚ My Sweet Escape ɞ

toffii.neocities.org

12,758 views
62 followers
803 updates
0 tips
Begging and pleading for somebody to teach me how to keep the same layout when switching tabs. I used to just update my index + sitemap individually, but omg... I don't want to go back to that... v.v
cozyamanda's avatar cozyamanda 49 minutes ago

i'm not 100% sure if it's applicable but i think you can achieve this with javascript. i believe i'm doing this on my site by flipping through the 'tabs' or different sections of my site. you can check the bottom of my index code if it's helpful. i hope someone else is able to chime in with more useful info!

1 like
toffii's avatar toffii 44 minutes ago

@cozyamanda Thank you, Amanda, for letting me looksie! 🥹 I'm going to do a lot of trial and error and see what I can come up with LOL!!

1 like
chiisana-wasurenagusa's avatar chiisana-wasurenagusa 38 minutes ago

easiest beginner-friendly fix is to put your shared layout (header, nav, footer, etc.) in one JavaScript file so you only have to edit it once. Create a file called layout.js in your root folder and put something like this inside it:document.addEventListener("DOMContentLoaded", function () { if (!document.body.classList.contains("no-layout")) {

2 likes
chiisana-wasurenagusa's avatar chiisana-wasurenagusa 37 minutes ago

document.body.insertAdjacentHTML("afterbegin", headerEl); document.body.insertAdjacentHTML("beforeend", footerEl); } });

1 like
chiisana-wasurenagusa's avatar chiisana-wasurenagusa 36 minutes ago

const headerEl = ` <header> <!-- your header / nav HTML goes here --> <nav> <a href="/">Home</a> <a href="/about.html">About</a> <!-- etc --> </nav> </header> `;

1 like
chiisana-wasurenagusa's avatar chiisana-wasurenagusa 36 minutes ago

const footerEl = ` <footer> <!-- your footer HTML goes here --> </footer> `;

1 like
chiisana-wasurenagusa's avatar chiisana-wasurenagusa 35 minutes ago

Put all these lines in one .js. on every page, put this in the <head> (or just before the closing </body>): <script src="layout.js"></script>

1 like
chiisana-wasurenagusa's avatar chiisana-wasurenagusa 34 minutes ago

Just don't forget to put relative paths if you have any subfolders like I do.

1 like

Website Stats

Last updated 10 minutes ago
CreatedJan 21, 2025

Tags

personal blog pink cute cutecore