Open stratofax opened 9 months ago
@stratofax I have added a meta description tag for testing purpose, how many meta tag do you want to use?
@ratulkhan74 Just the description
meta tag is required at this point to improve our SEO score on Lighthouse. Where are you pulling the description data from? Are you using the post or page excerpt? Please link to the code and line number to show me.
@ratulkhan74 Please link this to #24
@ratulkhan74 Just the
description
meta tag is required at this point to improve our SEO score on Lighthouse. Where are you pulling the description data from? Are you using the post or page excerpt? Please link to the code and line number to show me.
I have added the discription
meta tag and pulling data from the tagline that wordpress by default do. In the block theme there is no option that we can use the meta tag directly so we have to use the functions.php
file to insert the meta tag in the head.
Here is the code:
if (!function_exists('pico_added_meta_tags')) { function pico_added_meta_tags() { $description = esc_html(get_bloginfo("description")); echo ''; } add_action('wp_head', 'pico_added_meta_tags'); }
@ratulkhan74 I want to pull the meta description tag from the WordPress excerpt field, not the site description. I think we should handle this on a separate branch as well. See #28 for details on how I want to handle Issues and PRs in the future.
@stratofax Do you want to add any meta field in the settings for the meta description? or naywhere else?
@ratulkhan74 I'm sorry, but I don't understand your comment. I'd like to use the contents of the Excerpt field as the meta description.
One possible choice is code like this:
function my_theme_meta_description() {
if (is_single()) {
global $post;
$excerpt = strip_tags($post->post_excerpt);
$excerpt = (empty($excerpt)) ? strip_tags($post->post_content) : $excerpt;
$excerpt = substr($excerpt, 0, 155); // Adjust length as needed
echo '<meta name="description" content="' . esc_attr($excerpt) . '" />' . "\n";
}
}
add_action('wp_head', 'my_theme_meta_description');
Another possible choice is to require the Yoast plugin, which will do this automatically. I like this option the best, because Yoast is a good addition.
@stratofax if we submit our theme on any platfrom like wordpress or themeforest then we cannot use the Yoast
plugin for getting the meta description. also the SEO dosen't metter for market place items if you use this item for your personal use then it will metter. And about the code you are getting meta description from blog post you have to understand that we are developing a product not our client project we don't need anything like this we just need a good looking product who will install our theme they will check our home page first if they like our theme in frist look then they will install our theme otherwise it is not going to work how many features you include it's absulutlly doesn't metter.
@ratulkhan74 I know that when you install some themes, they recommend that you install additional plugins. I agree, we don't need to code this feature, instead we should recommend that people install the Yoast plugin. I think we can do that in the home page content, or the documentation that appears on WordPress.
Therefore, I'd like you to remove the code you added to insert the meta description tag, since this essentially "hard codes" the description tag for every post and page, and that's not OK.
@stratofax meta description code has been removed. Here is the PR link : https://github.com/cadentcom/pico-wp-block-theme/pull/31
If we add this meta tag, we should be able to score 100 x 4 on Google Lighthouse.