4 ms·
> Yes, you must copy and paste content Manual work is almost never a good solution. Try this: for PAGE in *.page do cat header.html "$PAGE" f
by liontwist 2y ago
> Yes, you must copy and paste content
Manual work is almost never a good solution. Try this:
for PAGE in *.page
do
cat header.html "$PAGE" footer.html > “$PAGE.html”
done
- adamzochowski 2y agoWhy not use server side includes? Most web servers support it, and it dates back to one of the early features of webservers. <!--# set var="pagetitle" value="Main page" --> <!--# include file="00__header.html" --> ... main content here <!--# include file="00__footer.html" -->
- liontwist 2y agoBecause that requires a server with the proper config and this is an HTML file. So it works in every environment, like locally on your machine, or GitHub pages.
- 8n4vidtmkvmk 2y ago`cat` supports multiple files, no? The whole point is that it concatenates. Why use 3 commands?
- AdieuToLogic 2y agoA slightly simpler version of same is: for PAGE in *.page do cat header.html "$PAGE" footer.html > "$PAGE.html" done As noted in a peer comment, the cat[0] command supports concatenating multiple files to stdout in one invocation. HTH EDIT: if you don't want the output file to be named "a.page.html" and instead it to be "a.html", replace the above cat invocation with: cat header.html "$PAGE" footer.html > "${PAGE%.page}.html" This syntax assumes use of a POSIX/bash/zsh shell. 0 - https://man.freebsd.org/cgi/man.cgi?query=cat&apropos=0&sektion=0&manpath=FreeBSD+14.2-RELEASE+and+Ports&arch=default&format=html https://man.freebsd.org/cgi/man.cgi?query=cat&apropos=0&sekt...
- vaylian 2y agoUnfortunately, this doesn't adjust the <title> element.
- johnisgood 2y agosed? :D
- liontwist 2y agoenvsubst