New Theme, New Code

Posted: Sunday, 4th November 2018

New Theme

Well, you're looking at it, the new theme for my site. I'm gonna be honest, it looked better in Affinity Photo than it does on here LOL. Oh well. I'd still like to think it's at least a slight upgrade from what I had before. If you like the old theme better, you can switch to it below in the footer, and it'll be saved for next time you come back, thanks to the awesomeness of JavaScript localStorage!

Oh yeah! And the site is also a little more optimised for mobile devices. Gnarly!

New Code

I've also completely re-coded the site, it's now mostly powered by JavaScript. The theme, navigation and page code, are now all separate, meaning whereas before, if I wanted to alter the navigation or theme, I'd have to do it on every single page. Now, I can just edit the theme, or just edit the navigation, and it will automatically be applied to every page.

In addition, the page's <title> element is now automatically generated based on which page you're on which saves some time. And I can also add BBCodes, like say, [YOUTUBE], to my page processor, to save having to copy and paste all that YouTube embed HTML every time.

The slight catch here is that all but the home page URLs have changed, so Google's gonna have to re-index everything, and the two people that visit my site will have to update their bookmarks. D'oh! Sorry xD.

The way the site code works is that it gets which page has been requested from the URL from a parameter, page, so for this page, if you look at the address bar now, the requested page is "blog/2018-11-04-new-theme-new-code". An XMLHttpRequest is then done to the server for that page as well as the currently selected theme. It then mixes it all together and boom there's your final page :).

Edit (Sun 11th November 2018): There's been a few changes. It's the same basic idea, but now the page is determined using the actual filename e.g. somepage.html, ratheer than using index.html for everything.

What's Next?

I have an idea for a small project which y'all, especially other Neocities members, might appreciate. You can use it to generate some fun, interactive content which you can put on your website, which your visitors might enjoy! I think I can create it in a day or two's work, so next time I'm not working on real life or my Crash 1 N. Sane playthrough, I'll get that done! I'll provide more details nearer the time.