Link to home
Start Free TrialLog in
Avatar of Daniele Brunengo
Daniele BrunengoFlag for Italy

asked on

Best way to include html with php and have Google not index the html

Hello. So, I have this menu I'd like to keep as a separate html file and include with php.

I was wondering though, if I keep the menu.html file in the same folder as the actual pages and include it with:

<?php include 'menu.html';?>

Open in new window


what's the best, lightest way to make Google and other SE not index menu.html?

Would it be better to have a menu.php instead?

I know php works server side, so the page will look just the same to SEs as it would with the full menu code as part of the page.

Like this:
<?php include 'menu.php';?>

Open in new window


But I was wondering how to keep SEs from seeing the menu's code as a separate page.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Daniele Brunengo

ASKER

If I use menu.php instead of menu.html will this work better or is it just the same as far as Search Engines are concerned?
It's all the same to a Search Engine.
Ok, thanks. I knew about robots.txt, I was hoping there was a more efficient alternative but I guess there isn't.
The sure fire way is to move the menu.html to a password protected directory and modify the .htaccess file (assuming Apache Web Server).

You can also include a noindex meta tag in menu.html (though not fool proof).

<meta name="robots" content="noindex">
If 'menu.html' is not linked by itself anywhere on your site, it will be invisible to search engines.  Including it in a PHP file does not expose the file name to the outside world.
Very interesting info Dave Baldwin, thanks.