0

I am creating a pure HTML website and in order to avoid the hassle of changing the menu, for example, on all the pages I've used something like

<div id='menu'></div>
<script>
    $(document).ready( function() {
        $('#menu').load('menu.htm #menu');
    });
</script>

But I've seen the this procedure actually affects SEO (and can't create for example, sitemaps), as JS is not crawled, so I'm actually wondering if there is any other way to include the DIVs from another HTML file in multiple HTML files by using another procedure, like through PHP.

Thanks!

  • Yes create a "header" file containing the shared content and use PHP's `include` command. Same for the footer. – ADyson Feb 10 '21 at 07:59
  • Another small question, do you know if it would be possible to have, for example, in the same php source file the header and footer php content and load it on pages different, like the above js would load only the div. – NoOneImportant Feb 10 '21 at 08:22
  • Not really no, you need the different snippets in different files - unless you make a more sophisticated structure in which you send an AJAX request to the PHP script, with the ID of the content you want, and then a PHP function fetches that specific content and returns it. (That's the basic foundations of your own CMS, right there!) – ADyson Feb 10 '21 at 09:19
  • Yeah, I thought so...I'm ok with html/css/some js, but when it comes to PHP, it's out of my league. I've managed to create in 30mins a php structure and I think it's what I need, either way... Thank you very much for the answer, it saved me hours of searching and testing! – NoOneImportant Feb 10 '21 at 09:35
  • No problem. P.S. If you're ok with JavaScript (even basic JavaScript) then you could probably pick up some PHP, enough to do the odd useful thing, without a big amount of trouble. It's a popular language, there are billions of tutorials, a very active PHP community here and elsewhere for support, etc. – ADyson Feb 10 '21 at 09:40

0 Answers0