Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Upload an HTML File to WordPress (2 Ways)

· 5 min read · Home Tech

In this article
  1. What You’ll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Uploading your own HTML file to WordPress lets you add custom pages, landing pages, or interactive tools that the standard editor can’t easily create. You’ll need either the built-in Media Library or the Theme File Editor, depending on whether you want a standalone page or a template file. Both methods are covered below, with exact steps for current WordPress versions.

What You’ll Need

  • A WordPress site where you have admin or editor access (for the Media Library method) or at least the ability to edit theme files (for the template method).
  • The HTML file you want to upload, saved as a .html or .htm file.
  • For the template method, a code editor (like Notepad++ or VS Code) to edit the file if needed.
  • A way to access your site’s files via FTP or the hosting file manager if you choose the more advanced template method.

Step-by-Step

Method 1: Upload via the Media Library (Simplest)

  1. Log in to your WordPress admin dashboard (usually yourdomain.com/wp-admin).
  2. Go to Media → Add New in the left sidebar.
  3. Click the Select Files button and choose your HTML file from your computer, or drag and drop it into the upload area.
  4. Wait for the upload to finish. You’ll see the file appear in the media library.
  5. Click the file name to open its attachment details. Copy the File URL (e.g., https://yourdomain.com/wp-content/uploads/2025/01/myfile.html).
  6. Now you need to make that URL accessible as a page. Go to Pages → Add New.
  7. Give the page a title (like “My Custom Page”).
  8. In the page editor, click the + (block inserter) and add a Custom HTML block.
  9. Inside that block, paste the following code, replacing the URL with the one you copied:
    <iframe src="https://yourdomain.com/wp-content/uploads/2025/01/myfile.html" style="width:100%; height:600px; border:none;"></iframe>
  10. Click Publish or Update to make the page live.
  11. Visit the page on your site to confirm the HTML file displays correctly inside the iframe.

Method 2: Upload via the Theme File Editor (More Control)

  1. Prepare your HTML file: if it’s a standalone page, make sure it contains a full HTML document (<!DOCTYPE html>, <head>, <body>). If you want it to use your theme’s header/footer, you’ll need to add WordPress template tags (like get_header() and get_footer()) – this requires PHP knowledge.
  2. Log in to your WordPress admin and go to Appearance → Theme File Editor.
  3. In the right-hand file list, look for the theme’s main folder (e.g., twentytwentyfour).
  4. Click Add New File at the top of the file list.
  5. Enter a filename with a .php extension, like custom-page.php – WordPress won’t execute raw HTML files from the theme editor, so you must use PHP.
  6. In the file content area, paste your HTML code. If you want the theme’s header and footer, add <?php get_header(); ?> at the top and <?php get_footer(); ?> at the bottom.
  7. Click Update File to save.
  8. Now create a page template: go to Pages → Add New, give it a title, and in the right sidebar under Page Attributes, select your new template (e.g., “custom-page”) from the Template dropdown.
  9. Publish the page. Your HTML will now display within the theme’s design.
  10. If you don’t see the template dropdown, you may need to add a comment at the top of your PHP file: <?php /* Template Name: Custom Page */ ?> and then re-upload the file via FTP or the theme editor.

Common Mistakes

  • Using the Media Library for a standalone page: The iframe method works, but the HTML file remains separate from your theme. If you need the page to look like your site, the template method is better.
  • Forgetting the iframe height: If you set a fixed height, content may be cut off. Use a large enough height or use JavaScript to auto-resize.
  • Not adding the template name comment: Without /* Template Name: ... */, the template won’t appear in the Page Attributes dropdown.
  • Uploading raw HTML to the theme editor: The theme editor expects PHP files. Uploading a .html file there will not work – you must rename it to .php and add the necessary PHP tags.

Tips

  • For the iframe method, consider using a plugin that allows you to embed HTML directly into a page without an iframe, but the built-in Custom HTML block is sufficient for most cases.
  • If you use the template method, create a child theme before editing templates to avoid losing changes when the parent theme updates.
  • Always test your HTML file locally (just double-click it) before uploading to ensure it works and has no broken links.
  • For security, avoid uploading HTML files that contain sensitive data – anyone with the URL can view them.

Troubleshooting

  • The iframe shows a blank page: Check that the file URL is correct and the file exists. Also, ensure your HTML file doesn’t have a redirect or a script error that prevents rendering.
  • The template doesn’t show in the dropdown: Clear your browser cache and re-check the file’s comment. Also, ensure the file is saved with a .php extension and placed in the correct theme folder.
  • Changes don’t appear: WordPress may cache pages. Install a caching plugin or clear your site’s cache from the hosting panel.
  • Permission errors when uploading: If you get a “failed to write file” error, check your folder permissions (usually 755 for directories, 644 for files). Contact your host if needed.

Frequently Asked Questions

Can I upload an HTML file without making it a page?

Yes, you can upload it to the Media Library and share the direct URL, but visitors will see the raw HTML file without your theme’s navigation. Most users prefer to embed it in a page.

Why can’t I see the Template dropdown in the page editor?

This usually happens when the PHP file doesn’t have the /* Template Name: ... */ comment at the very top, or the file is in the wrong theme folder. Double-check both.

Can I upload an HTML file to WordPress.com (hosted version)?

On WordPress.com’s free plan, you cannot upload HTML files directly. You’ll need a business plan or higher to use plugins or upload files. The steps above apply to self-hosted WordPress.org sites.

Is it safe to upload HTML files?

Yes, as long as the file contains only static HTML, CSS, and JavaScript. Avoid uploading files with server-side code (PHP) unless you know what you’re doing, as they could be a security risk.

What if my HTML file uses JavaScript that doesn’t run?

If the JavaScript relies on external libraries, make sure the URLs are correct and the file is loaded over HTTPS. Also, check for browser console errors – right-click, select Inspect, and look at the Console tab.

Can I use a child theme for the template method?

Yes, it’s recommended. Place your custom template file in the child theme’s folder, and it will work just like in the parent theme, but your changes won’t be lost on updates.