+ 1
Navigation bar with links
If my website contains more than one page, should I write nav code in each and every page to visible my navigation bar in all those pages or Is there any other process to avoid writing nav code? Pls don't recommend copy and paste.
3 Answers
+ 3
You could make a single file with nav only.
And the include it in each file.
this will allow you to edit on 1 place and affects on every place.
this needs php
+ 3
It depends on how you define "page". You can create a page-like effect without creating separate files. That way you won't need to worry about duplicating code or using a backend language.
Here's an example:
https://www.coopertech.co
You can view-source on that.
That's my client's website, so if you end up reusing the code, you'll need to ask them for permission.
I created it this way so it would load once and load quickly. Clicking each link doesn't result in additional server calls because it's all in the same file.
I hope this helps!
PS I'm going to add some tags to improve this thread's searchability.
+ 1
in php, python django or any other back end you can just include same html file to many other html pages. that's it.
in js you can write function on load
Actually by nav you are asking about classic menu
For that use ul li a