I need to insert some code directly below the opening
<head> tag. Adding the code to the usual head section in settings isn’t working, as RW adds the code between the
<head> </head> tags, but not as the first item.
Does anyone know of a way to solve this?
I know I can add the code manually, but I know that at some point I’ll republish the page, forget, and so break the page.
I have found that one solution is to add
<head> code here </head> to the prefix, but of course that will then result in two sets of head tags. I know officially this is not a good idea, but I’m wondering how bad an idea it is. I know I’ve done things like this in the past and seen no side-effects, but I also know browsers are far less forgiving nowadays, and Google is a bugger for things like this now, so I’d appreciate some opinions.
If you have jquery in scope then you can retrofit the element using something like:
Not knowing what you’re adding to the head section makes it difficult to say for sure.
I wouldn’t add two head sections, since that’s technically an error you don’t know what impact it has or will have in the future. Even though it might seem to be okay today the next update to a browser could “break” it.
Is what you are putting in the head section static on every page? If so have you thought about changing the theme?
I’m using UIkit, and changing the framework isn’t an option.
The code to be inserted is this:
<base href="https://www.guidebookspain.com/guides/index.php" />
It’s purpose is to fix any CSS issues after applying some SEO tricks to the htaccess file pertaining to a PHP script on the page.
It works perfectly, but only if inserted as the very first thing in the head section.
Adding the following to the prefix works, but as discussed, not keen on having two head section.
<html lang="en-gb" dir="ltr">
<head><base href="https://www.guidebookspain.com/guides/index.php" /></head>
@indridcold That’s an interesting idea, but I’m clueless on such things. Are you able to help?
I did some Googling, and I think it might be possible to add it in the correct place using some PHP, but again, even though I found some potentially suitable code, I couldn’t work out how to make it work.
All help appreciated.
Don’t know why that wouldn’t be an option. I don’t have UIKit but the Theme on most frameworks are much simpler than the themes on traditional Themes. Unless UIKit changes the theme a lot I don’t see why that would be an issue
Never heard of that before. The Specs doesn’t mention this, so the PHP script that’s using this must not be finding it if it’s in another location.
I wouldn’t consider having two head sections, over have of web traffic is “non-human” or screen-readers. Having two head sections will probably break something you haven’t even thought of. Plus the code you show above looks to add an additional
<html tag? That’s another error.
Is this only for a single page?
If it’s for a single page, I’d change the Theme for that single page.
I don’t have UIKit but here’s how with Foundry:
- Duplicate the theme
- Right-Click the duplicate and select Show in Finder
- In most themes, the base HTML is in index.html. Open with a text editor
- Make the changes to that and save
Set the theme for the one page to the copy.
Changing the theme isn’t an option.
At present I’ve added the code into the position needed manually, but I like the idea of editing the base theme. Good idea.
SEO Helper allows you to place meta tags inside head. It even has out of the box support for the base meta tag…
Have you a link to page using SEO Helper?
Another option would be to duplicate the UIkit theme first, then on the duplicated theme move the
%user_header% to where you want it to be, right under the
Sounds the perfect solution.
I want to add this bit of code to a lot of uikit projects, so I’ll use the edited theme on all these.
Just ran some tests, and works perfectly.
I’m now curious, is there any reason not to always put user_header at the top of the head section?
All of Weaver’s Space uses SEO Helper. Seems like you are going to be modifying the theme though. Good luck!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.