Search code examples
htmlgithub-pages

Github pages - how to reuse html code on each page (like a nav bar)


I found many answers to this question, but it was often outdated or I failed to make it work.

I have a nav-bar and I want to call it on each pages so when I want to update it, I need to change only one instance of the nav bar and not multiple instances on many pages.

How can I do it please? I am using Github pages, maybe it matters somehow.

Thanks


Solution

  • Github-pages uses Jekyll, which on its own uses Markdown and Liquid.

    If I've understood you correctly,
    You can achieve what you want by using include syntax in Liquid which is referenced here.

    You can find more information about include in here and this blog post.

    This project uses different scenarios of include.

    Github-pages is a powerful static site generator and you can achieve a lot by using it, checkout this list.