Link html using source - html

I have tried:
<html src="navbar.html"></html>
I have a file called navbar.html
Is there any way I could make it appear on every page I have?
I will be changing the navbar a lot throughout my website and I don't want to change it in all my 20+ pages. How can I make this one file appear in every page?
Would it be possible to make it in html rather than jquery and append it to every page?
something similar to
<script src="file.js"></script>
But html src

Why not just use PHP? As long as you're developing on a server (as PHP is server side) you can essentially change .html files to .php and include a file for the navbar. For example:
<?php include 'navbar.php'; ?>
Look up PHP include at http://php.net/manual/en/function.include.php. It will do exactly what you want. All you do is include the file on every page and it will be reflected in every page .

Visit our HTML tutorial
The href attribute specifies the destination address (http://www.w3schools.com/html/) of the link.
The link text is the visible part (Visit our HTML tutorial).
Clicking on the link text will send you to the specified address.
http://www.w3schools.com/html/html_links.asp

Related

Creating a plain html home page AMP with WordPress running the other pages

Gday
I like to know how you would go about creating a home page in plain html and have WordPress run the other pages?
The reason is I’d like to create a solely plain html website but I need WordPress for my contact page it has a large form on it and I use a plugin to generate it and forms are a bit beyond my knowledge at the moment to create a contact page myself.
(I have tried creating a template page but then WordPress adds unnecessary code [from plugins ] and makes the AMP invalid)
Honestly I'd try and keep it self contained in WordPress itself.
If for some reason you really want a separate HTML/PHP Homepage, follow these steps:
Add a my-homepage.php file to your /wp-content/themes/ACTIVE-THEME directory
Inside that file put the following code:
Add a new page (Pages > Add New)
Give it a recognizable name like "My Homepage"
In the "Template" selector on the right hand side, pick "My HTML Homepage" and click Publish
Go to Settings > Reading, change Your homepage displays to A static page and pick the page you just made
Now you can add your own code as you see fit. Nothing "WordPress" related will get loaded or hooked in since there's no functions on that file - so you're free to code HTML (or PHP) to your heart's content.
You can see a bit more indepth answer over on WPSE: https://wordpress.stackexchange.com/questions/296592/how-to-use-custom-html-file-instead-of-wordpress-homepage

Link html file to another html file

Say I have a webpage with multiple html documents
ex:
Homepage.html Aboutme.html Contactinfo.html
And at the bottom of all of these pages I want a little message
"Hello and welcome to my website"
But I want to change that later on to something else
"I hope you enjoy my website"
Can I have a separate Html document linked to my other html documents to easily change the code without having to go to each document
So like footer html will contain
<p>"Hello and welcome to my website"</p>
And it shows up on all my pages
then later I change it to
<p>"I hope you enjoy my website"</p>
and then it changes on all my pages
similar to how you can link css files but instead with code
You cannot do this with only HTML - it lacks that capability.
You can do this with PHP, it is called a server-side include, and looks like this. Each page would have, embedded amongst the HTML:
<p>Paragraph on this page</p>
<?php include 'inc/message.inc.php'; ?>
<p>Another paragraph of information</p>
The above would load the contents of a file called message.inc.php and stored inside a folder called inc.
Alternately, you can use jQuery (javascript):
$('.msg').load('inc/message.inc.php');
But first you would need to create an HTML tag with that classname (note the link there - .msg with class="msg") msg could be a P tag, a div, a textarea, section, some kind of container.
<p class="msg"></p>
The PHP include is the better solution because the javascript will run after the DOM has been rendered, which might display a quick flash when the message is injected into the P element.
All that is required to use a PHP include is to use the .php file extension instead of .html -- that's it. If your webserver can do PHP (and most can), then it will instantly work.
Note that using the .php extension will not cause any problems with the HTML/CSS/javascript -- all of that will continue to work as before. The only difference is that NOW it can also handle PHP.
The file message.inc.php could simply be this:
message.inc.php
<p>Your cool message goes here</p>
That's it!

HTML remove url variables, NO PHP or JS solution

My site uses both PHP and the JS AJAX so I'm fairly familiar with them both, and I don't want a solution that includes them. I have this page structure where all my users stay on just one landing php page, which then fetches the right content depending on the URL's p variable.
http://www.example.com/?p=about
http://www.example.com/?p=aMap-anothermap-evenAnothermap-lastelyTheFile
This page structure works great for me except that I don't know the right way to make a link that just removes the whole ?p=home. Because I want my home/start page to be variable free. I want it to be
http://www.example.com/
rather than
http://www.example.com/?p=home
Now I could just make the link
http://www.example.com/?
And then just remove the ? with the JS pushState(), but that would look pretty silly and would only work for JS users.
Let's say i would want to the do the above example with just the ? then I could create a link like this.
Link
<script src="SomeCoolPushStateScript"></script>
And I know from experience that this doesn't even work:
Link
So here comes the question: How do I remove the ?variable=something part of an URL when using an HTML href?
The path ./ should do the trick.
Link
If you want to preserve the main script name, like index.php, you will have to include that name.
Link
Alternately, you could dynamically generate domain-relative or absolute URL's with PHP.
You don't need to use querystrings.
Link
would go to example.com's root.
I don't recommend using "./". This would do what you want if the user is on a page that is in the root directory of your website (e.g. http://www.example.com/page.html). However, this would not work if they were on a page in a subdirectory. E.g. if the user's on http://www.example.com/hello/page.html, it would just link to http://www.example.com/hello/.
Using "/" makes sure the user goes to the root of your website.

Adding a .css file into sharepoint

I am trying to include this line of html into a sharepoint 2007 content section inside a page i have just created. I am the owner.
<link rel="stylesheet" type="text/css" href="/sites/gskglobal/mcLaren-partnership/Documents/live.css" />
I input this using Edit HTML Source on a piece of content (This was the only way i could find out how to input HTML directly).
When i click ok the styles display perfectly having already uploaded the css file.
When i click save it removes the entire link element and leaves me with no stylesheet.
i could put the styles in line, but i really don't want to do this.
N.B no erros are displayed only
Warning: The HTML source you entered might have been modified.
Both of those will work, however the CSS may get executed AFTER the SharePoint Page is rendered.
The short and simple way is to add the CSS file to any document library (Style Library too). Add the Link script above into a text file and upload that. Add a Content Editor Web Part to the page and through the settings, point it to the TEXT file with the script.
The CEWP part is executed during the HTML creation process when building the page thus the CSS gets executed with the header (like the rest of the CSS for SharePoint).
Try adding your .css file to your main web "Style Library"
You need only to publish your css file
Go to your all document view
find your file
publish
The best and easiest way I found to add any form of html into the document when adding a webpart simply add a form then edit the html as you would normally and this will no longer give you the
Warning: The HTML source you entered might have been modified.
It will just leave the markup in there without sharepoint stripping or editing your markup
Just wanted to make people aware that this is possible and maybe an option if you don't have access to the other suggests.

Insert Code Into HTML

I have a web site that gets a new page every couple weeks, and that means I need to update the menu to have the new page in every single one. I'm wondering if there is a way to have an external text or .htm file that I can basically insert into the web page. That way I can put the menu in the external file and call it wherever I want it. So I only have to edit one thing when I get a new page.
Thanks in advance.
Edit: This is a drop-down menu with ul and li tags with an external style sheet for them. So this needs to work for that too. Thanks
Have a single HTML page like so:
<html>
<head></head>
<body>
HTML OF LINKS HERE
</body>
</html>
Then save it as my_links.html and into the page you want to insert it... do the following. Copy and paste the whole page and it as FILENAME.PHP and then use this code:
<?php include("my_links.html"); ?>
Congratulations, you have just used PHP! Learn more about the including pages here.
This is very easy and common to do on sites that use a server-side language behind them (PHP, ASP.NET, etc.)
If you don't want to use a server side language, than an <iframe> is your only option.
If you want to use HTML, and only html (no server side programming or javascript), you can use Server Side Includes embedded into your html files. Your web server may need to be configured to accept them.
If you are using server side include and you had navigation in a separated file, yes you can just edit things separate.
You can also do this using jQuery.
$('#elementid').load('page.html');
http://api.jquery.com/load/
But this will not be SEO friendly.
Also if someone has scripts turned off in their browser, then this will not work.