Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
0

How to move a nav menu to its own document?

Explorer ,
Jul 03, 2017 Jul 03, 2017

Hi,

How would I move a completed Bootstrap nav menu  out of my HTML files so it's in its own document, so that changed can be made in one place instead of having to do it on every page? JQuery? What's the best way?

Thanks.

475
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 03, 2017 Jul 03, 2017

If PHP is available on your web hosting plan, use PHP Server-Side-Includes for your site wide navigation.

Alt-Web Design & Publishing: Server-Side Includes with PHP

Basically, 1 include file contains only the relevant HTML menu code & nothing more.   It's not a complete document, it's a code fragment.   Depending on your Bootstrap menu, you will copy & paste just the navbar code into a new file and name it navbar.html or navbar.ssi or whatever you like.

The parent pages in which the include stat

...
Translate
LEGEND ,
Jul 03, 2017 Jul 03, 2017

The first thing I and most people will ask -

'Do you have PHP available on your server'?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2017 Jul 03, 2017

If PHP is available on your web hosting plan, use PHP Server-Side-Includes for your site wide navigation.

Alt-Web Design & Publishing: Server-Side Includes with PHP

Basically, 1 include file contains only the relevant HTML menu code & nothing more.   It's not a complete document, it's a code fragment.   Depending on your Bootstrap menu, you will copy & paste just the navbar code into a new file and name it navbar.html or navbar.ssi or whatever you like.

The parent pages in which the include statement occurs will need to be renamed with a .php extension.  Most shared web hosts do not parse PHP code in ordinary .html files.  If unsure, check with your hosting provider.

Nancy

Nancy O'Sheaā€” Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 04, 2017 Jul 04, 2017

Thank you. Yes, my hosting company does offer .php.

For an existing site with all .html pages, including index.html, what's the best way to handle the search engines as far as them all changing to .php pages? Leave the .html pages but delete the content and have links to their .php versions? 301 Redirects?

Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2017 Jul 04, 2017
LATEST

I would replace all .html files with .php.

301 Redirect old .html to new .php files.

Add a robots.txt file to your server & Disallow any folders or file types you don't want indexed.

Add a new sitemap.xml to your server with the new .php pages.

Log-in to your Google Webmaster Tools account and ask Google to re-index your site.  

Nancy

Nancy O'Sheaā€” Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines