Add meta keywords directly to your WordPress theme files
Meta keywords are HTML tags that tell search engines what your page is about. Most modern search engines ignore them, but some still read them, and adding them costs nothing. You can put them in your WordPress site without installing a plugin by editing your theme's header file directly.
The process takes about five minutes and requires access to your theme files through the WordPress editor or your hosting control panel. You will add a single line of code to your theme's header.php file, then customize it for each page or post using WordPress's built-in custom fields.
This approach works on any WordPress theme and gives you full control over what keywords appear on each page. If you make a mistake, you can undo it in seconds.
Key Takeaways
- Meta keywords go in your theme's header.php file as a single line of code that pulls from WordPress custom fields.
- You access header.php through WordPress's Theme File Editor (Appearance > Theme File Editor) or through your hosting control panel's file manager.
- After adding the code, you set keywords for each post or page using the Custom Fields box in the WordPress editor.
- Search engines like Google do not use meta keywords for ranking, but some smaller search engines and social platforms still read them.
- If you edit the wrong file or add code incorrectly, your site may break — always back up your theme files first.
Back up your theme before editing files
Before you touch any theme files, download a copy of your entire theme folder to your computer. If something goes wrong, you can restore it in minutes instead of spending hours fixing a broken site.
Log into your hosting control panel (usually cPanel, Plesk, or your host's custom dashboard). Open the file manager, navigate to public_html/wp-content/themes/[your-theme-name], right-click the theme folder, and select Download or Compress. Save the file to your computer.
If your hosting control panel does not have a file manager, use an FTP client like FileZilla. Connect to your host using the FTP credentials from your hosting account, navigate to the themes folder, and download the entire theme folder to your computer. Keep this backup until you confirm the keywords are working.
Find and open your theme's header.php file
The header.php file is where WordPress puts code that appears at the top of every page on your site. This is where meta tags live. You can edit it directly from WordPress without touching your hosting control panel.
Log into your WordPress dashboard. Go to Appearance in the left menu, then click Theme File Editor. On the right side, you will see a list of your theme's files. Look for header.php and click it.
The file will open in a text editor. Look for the line that says </head> — this marks the end of your page's header section. Meta keywords must go just before this closing tag. Do not edit anything else in this file.
Add the meta keywords code to header.php
Place your cursor on a blank line just before </head>. Copy and paste this code exactly:
<meta name="keywords" content="<?php echo get_post_meta(get_the_ID(), 'keywords', true); ?>" />
This code tells WordPress to look for a custom field called "keywords" on each page or post and put whatever you type there into the meta tag. If no keywords are set, the tag will be empty — that is fine.
Click the Update File button at the bottom right. WordPress will save the change. Your site should still work normally. If you see an error message, click the back button in your browser, delete the code you just added, and click Update again to undo it.
Set keywords for individual posts and pages
Now that the code is in place, you can add keywords to any post or page. Open the post or page you want to add keywords to. Scroll down on the right side of the editor until you see a box labeled Custom Fields.
If you do not see the Custom Fields box, click the three dots menu at the top right of the editor, select Preferences, scroll down, and check the box next to Custom Fields. Close the preferences and the box will appear.
In the Custom Fields box, click Add New. In the Name field, type keywords (exactly as written). In the Value field, type the keywords you want for this page, separated by commas. For example: wordpress seo, meta tags, search optimization. Click Add Custom Field, then save or update your post.
Repeat this step for any other posts or pages where you want keywords. You do not have to add keywords to every page — only the ones where you want them.
Check that your keywords are showing up
Visit one of the pages where you added keywords. Right-click anywhere on the page and select View Page Source (or Inspect in some browsers). Press Ctrl+F (or Cmd+F on Mac) and search for the word keywords.
You should see a line that looks like this:
<meta name="keywords" content="wordpress seo, meta tags, search optimization" />
If you see this line with your keywords inside, the code is working. If you see an empty meta tag with no content, check that you spelled "keywords" correctly in the Custom Fields box — it must be lowercase.
If you do not see a keywords meta tag at all, go back to header.php and make sure the code is there and is spelled correctly. A single typo will break it.
Remove or update keywords later
To change keywords on a page, open that page in the WordPress editor, find the Custom Fields box, and click the pencil icon next to the keywords field. Type the new keywords and click Update.
To remove keywords from a page entirely, click the trash icon next to the keywords field in the Custom Fields box. The meta tag will disappear from that page the next time someone visits it.
If you ever want to remove the meta keywords code from your entire site, go back to Appearance > Theme File Editor, open header.php, delete the line you added, and click Update File. The meta tags will stop appearing on all pages.
Frequently Asked Questions
Do search engines actually use meta keywords?
Google stopped reading meta keywords in 2009 and does not use them for ranking. Bing and Yahoo still read them but weight them very lightly. Some smaller search engines and social media platforms do use them. Adding keywords costs nothing and does not hurt, so many sites include them anyway.
What happens if I add the code wrong?
If you make a typo or add the code in the wrong place, your site may show a blank page or an error. Do not panic — go back to header.php, find and delete the code you added, and click Update. Your site will return to normal. This is why backing up your theme first is important.
Can I add different keywords to different pages?
Yes. The code pulls keywords from the Custom Fields box on each individual post or page. You can set different keywords for every page, or leave some pages without keywords. Pages without a keywords custom field will have an empty meta tag, which is fine.
What if my theme does not have a header.php file?
All WordPress themes have a header.php file. If you cannot find it in the Theme File Editor, your theme may be using a block-based theme (newer WordPress themes). For block themes, use a plugin or contact your theme's support — editing code in block themes is more complex.
Can I use this method on a WordPress.com site?
No. WordPress.com does not allow you to edit theme files directly. You would need to use WordPress.org (self-hosted) or contact WordPress.com support about meta keywords. Most WordPress.com plans do not support custom meta tags without a paid upgrade.