Skip to main content
Participant
February 10, 2022
Question

How do I reuse my nav bar

  • February 10, 2022
  • 4 replies
  • 2556 views

I was wondering how would I reuse my nav bar, can I even do it in dreamweaver? I just want it so I have a nav.html and I can apply it to the new pages I may create.

    This topic has been closed for replies.

    4 replies

    Legend
    February 11, 2022
    quote

    I was wondering how would I reuse my nav bar, can I even do it in dreamweaver? I just want it so I have a nav.html and I can apply it to the new pages I may create.


    By @KeanuPotatoGod

     

     

    You don't need anything fancy, other than what's already available by default in your browser. Javascript is available out of the box so no set up like php, node, python etc is required.

     

    Just create a file and name it 'include_nav.js' - paste in the below code, the bold text being YOUR navigation html.

     

    const navbar = `
    <ul class="navbar">
    <li><a href="">Link 1</a></li>
    <li><a href="">Link 2</a></li>
    <li><a href="">Link 3</a></li>
    <li><a href="">Link 4</a></li>
    <li><a href="">Link 5</a></li>

    </ul>
    `
    document.querySelector('body').insertAdjacentHTML('afterbegin', navbar);

     

     

     

    Then in the page/s where you want the naviagtion bar included paste the code below just before your closing </body> tag:

     

    <script src="include_nav.js"></script>

     

    Thats it, you can update your navigation code in the js file and it will propogate to ALL pages which contain the <script></script>

     

    Of course IF you are using php, node, python then take advantage of the way those workflows allow you to include files (if youre using any of those then you probably wouldnt be asking the question anyway) BUT they are not strictly necessary if you have no desire to use any of them.

     

    Personally Id stay away from Dreamweaver .dwt templates because if you ever decide to move away from Dreamweaver your route to updating your navigation will be more difficult. Stay away from any kind of niche workflow or software as its a ticking time-bomb which may come back to bite you in the ass at some stage. 

    B i r n o u
    Legend
    February 11, 2022

    yes that is what is exactly said in the link I have proposed above your comment*

    https://stackoverflow.com/questions/38837835/include-html-in-another-html-file

    Legend
    February 11, 2022

    Well l wouldn't go to the extremes of including the jquery library unless you're already using it and whilst the object tag seems to be the simplest approach, it's browser support is currently still poor, as far as l know but l think there is something amongst those suggestions which would be useful, without having to deploy the heavy lifting gear (php, node, python, etc) if its not required.

    BenPleysier
    Community Expert
    Community Expert
    February 11, 2022

    Of late, I have been enjoying using Express as my templating engine while using Node as my server model. This templating engine functions in the same manner as the template engine built into Dreamweaver. But unlike Dreamweaver's templating engine, Express is not reliant on the IDE. There are many tutorials on Node/Express that use the freely available VS Code.  

     

    For me, I have chosen Wappler as my IDE to make it dead easy to setup a template, as this video will attest.

    https://youtu.be/ee4iwQpUQ2U

     

     

     

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Nancy OShea
    Community Expert
    Community Expert
    February 10, 2022

    You should look at Dreamweaver Templates (F1 in the Help Menu).  This method is suitable for small sites, under 50 pages.  

    https://helpx.adobe.com/dreamweaver/using/dreamweaver-templates.html

     

    PART 1: Create a Template.dwt file

    1. Start with an ordinary HTML document or Starter Template that contains all sitewide elements you will need --  i.e. header, navigation, footer, etc... 

    2. File > Save As Template.

    3. Add Editable Regions for content that will change from page to page. 

    4. Save Template and Close it.

     

    PART 2: Create Child Pages.

    1. Go to File > New > Site Templates.  Select your DWT file from 3rd column.

    2. Hit the Create Button. 

    3. Save As index.html (your domain's home page).

    Repeat for other site pages.

     

    Nancy O'Shea— Product User & Community Expert
    B i r n o u
    Legend
    February 11, 2022

    what is different from the above link... so funny ... 🙂

    Nancy OShea
    Community Expert
    Community Expert
    February 11, 2022
    quote

    what is different from the above link... so funny ... 🙂


    By @B i r n o u

    ========

    The difference is step-by-step instructions on how to set-up and use Dreamweaver's built-in Template feature.  A bit more information than random links. 

     

    I suppose I should have provided more detail about using server-side includes too, as they're more flexible than Templates. But whatever... 😍

     

    Nancy O'Shea— Product User & Community Expert
    B i r n o u
    Legend
    February 10, 2022

    well, there are so many way to include some content into an hosting page.

    it all depend on how stuffs are build (those links are pretty old, but they should help you to open the door)

     

    so

     

    you can use PHP include (http://www.dreamweaverclub.com/php-includes.php) - https://www.php.net/manual/en/function.include.php

    you can use SHTML - http://www.asrvision.com/web-design-tutorials/headers-footersn-in-shtml.htm 

    you can use JavaScript - https://stackoverflow.com/questions/38837835/include-html-in-another-html-file

    you can use Template - https://helpx.adobe.com/dreamweaver/using/dreamweaver-templates.html

    using Library item - https://helpx.adobe.com/dreamweaver/using/library-items.html