0

I am building a front-end website, no back-end code at all, since I want to host it on GitHub pages, and honestly adding any back-end would be overkill.

Is there a way to include common elements of the website in each webpage easily? For example, add a special tag that specifies which html file to replace that tag with and running a command that will do that and place it in a file which will be the final product? This is so I can have this instead of copy-pasting my nav-bar code whenever I make a small change for example.

Is there a NodeJS package for this?

I saw similar questions, however, they aren't exactly asking for the same thing as I'm looking for...

Yiannis128
  • 66
  • 1
  • 8
  • There's hundreds of tools for that, but it sounds like Jekyll is probably what you are looking for: https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/setting-up-a-github-pages-site-with-jekyll – dpwr Dec 12 '20 at 01:44

2 Answers2

1

What you're looking for is called a boiler plate. This should give you a good place to start.

When you say "No back-end code at all" do you mean - no database that stores information that your website displays, or do you mean you don't want to have any dedicated javascript files in your project and want to work on pure html/css? To me, it appears like you are talking about the latter - in that case, you can add some jquery to your code right in the html files by using the <script></script> tag.

MCA
  • 92
  • 6
0
<!DOCTYPE html>
<html>
<body>
<a href ="src/boilerPlate/header.html"></a>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href = "src/boilerPlate/footer.html"></a>
</body>
</html>

And your file tree would look like:

SRC
    >>index.html
    >>boilerPlate
             >>>>header.html
             >>>>footer.html
MCA
  • 92
  • 6
  • 1
    This isn't what I'm asking for though, since say you have a navigation bar that is across 10 static html webpages, you can't include it in all of them using this method... I'll just make a bash script that does it... Thanks for taking your time to help anyway. – Yiannis128 Dec 12 '20 at 02:29