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.
Daniele BrunengoIT Consultant, Web DesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
Disallow it in your robot.txt file.

Sample robot.txt file:

User-agent: *
Disallow: menu.html

Not fool proof. This might give you some more insight:

https://support.google.com/webmasters/answer/6062608?hl=en&authuser=0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
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?
Tom BeckCommented:
It's all the same to a Search Engine.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
Ok, thanks. I knew about robots.txt, I was hoping there was a more efficient alternative but I guess there isn't.
Tom BeckCommented:
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">
Dave BaldwinFixer of ProblemsCommented:
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.
Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
Very interesting info Dave Baldwin, thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Search Engine Optimization (SEO)

From novice to tech pro — start learning today.