How can I make my navi-bar the same across my html?

后端 未结 9 774
长发绾君心
长发绾君心 2020-12-05 13:26

With each new page I have to update the navigation panel. Which means I go from page to page copying and pasting my navigation bar. The more pages I add the harder it gets.

9条回答
  •  抹茶落季
    2020-12-05 13:57

    I'd strongly recommend using PHP:

    
    

    However, if that is not an option, you can use Server Side Includes:

    File in the same dir:

    
    

    File in a different dir:

    
    

    You'll need a Linux/Apache (not Windows) server for this to work. You'll also need to use the .shtml file extension.


    Alternatively, given that you want to keep .html extensions, you can make Apache "think" that all .html files are actually .php:

    Create a .htaccess file at the root of your website and add this line:

    AddType application/x-httpd-php .html .htm
    

    If your are running PHP as CGI (probably not the case), you should write instead:

    AddHandler application/x-httpd-php .html .htm 
    

    (Taken from this answer)

提交回复
热议问题