جاري التحميل...

Technical SEO – دليل شامل

O هو العمود الفقري لأي استراتيجية تحسين محركات البحث. الهدف منه هو تسهيل زحف وفهرسة موقعك من محركات البحث، وتحسين سرعة الموقع وتجربة المستخدم، دون الاعتماد فقط على المحتوى.

في هذا المقال، سنغطي أهم الجوانب التقنية للسيو مع أكواد عملية ضخمة جدًا تشمل:

  • تحسين العناوين والميتاداتا
  • تحسين الروابط الداخلية
  • إعداد ملفات Robots.txt و Sitemap
  • تحسين سرعة الموقع
  • استخدام Structured Data
  • تحسين الأداء للموبايل

القسم 1: تحسين العناوين والميتاداتا

1️⃣ إضافة Meta Description ديناميكي في WordPress

<?php
function custom_meta_description() {
if(is_single() || is_page()) {
$desc = get_the_excerpt();
} elseif(is_category()) {
$desc = category_description();
} else {
$desc = "مرحبًا بك في موقعنا، اكتشف أفضل المقالات.";
}
echo '<meta name="description" content="'.esc_attr($desc).'">';
}
add_action('wp_head','custom_meta_description');
?>

2️⃣ استخدام Meta Robots لمنع فهرسة صفحات معينة

<?php
function custom_meta_robots() {
if(is_tag() || is_date()) {
echo '<meta name="robots" content="noindex, follow">';
}
}
add_action('wp_head','custom_meta_robots');
?>

القسم 2: تحسين روابط الموقع (Permalinks) وCanonical

1️⃣ إضافة Canonical Tag ديناميكي

<?php
function add_canonical_tag() {
if(is_singular()) {
echo '<link rel="canonical" href="'.get_permalink().'">';
}
}
add_action('wp_head','add_canonical_tag');
?>

2️⃣ إعادة كتابة الروابط (Rewrite Rules)

<?php
function custom_rewrite_rule() {
add_rewrite_rule('^blog/([0-9]+)/?', 'index.php?p=$matches[1]', 'top');
}
add_action('init','custom_rewrite_rule');
?>

القسم 3: إعداد Robots.txt و Sitemap

1️⃣ مثال Robots.txt متقدم

User-agent: *
Disallow: /wp-admin/
Disallow: /wp-login.php
Disallow: /private/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://example.com/sitemap_index.xml

2️⃣ إنشاء Sitemap ديناميكي

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$posts = get_posts(array('numberposts' => -1, 'post_status' => 'publish'));
foreach($posts as $post){
setup_postdata($post);
echo '<url>';
echo '<loc>'.get_permalink($post).'</loc>';
echo '<lastmod>'.get_the_modified_date('c',$post).'</lastmod>';
echo '<changefreq>weekly</changefreq>';
echo '<priority>0.8</priority>';
echo '</url>';
}
echo '</urlset>';
wp_reset_postdata();
?>

القسم 4: تحسين سرعة الموقع

1️⃣ Lazy Load للصور

<?php
function lazy_load_images($content){
$content = preg_replace('/<img(.*?)src=/i','<img$1loading="lazy" src=',$content);
return $content;
}
add_filter('the_content','lazy_load_images');
?>

2️⃣ Minify CSS و JS

<?php
function minify_scripts() {
ob_start('compress_output');
}
function compress_output($buffer) {
$buffer = preg_replace('/\s+/', ' ', $buffer);
return $buffer;
}
add_action('get_header','minify_scripts');
?>

القسم 5: Structured Data (Schema.org)

1️⃣ JSON-LD للمقالات

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "عنوان المقال",
"author": {
"@type": "Person",
"name": "اسم الكاتب"
},
"publisher": {
"@type": "Organization",
"name": "اسم الموقع",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.png"
}
},
"datePublished": "2026-02-25",
"dateModified": "2026-02-25"
}
</script>

2️⃣ Breadcrumbs مع Schema

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type":"ListItem","position":1,"name":"الرئيسية","item":"https://example.com/"},
{"@type":"ListItem","position":2,"name":"المدونة","item":"https://example.com/blog"},
{"@type":"ListItem","position":3,"name":"Technical SEO"}
]
}
</script>

القسم 6: تحسين الموبايل

1️⃣ Meta Viewport

<meta name="viewport" content="width=device-width, initial-scale=1.0">

2️⃣ CSS Responsive

body {
font-family: Arial, sans-serif;
line-height: 1.6;
}@media (max-width:768px){
.container {
padding: 10px;
}
.breadcrumb {
font-size: 14px;
}
}

القسم 7: تحسين تجربة الزحف (Crawl Budget)

1️⃣ Robots Meta Tags

<?php
function prevent_index_tag() {
if(is_search() || is_tag()){
echo '<meta name="robots" content="noindex, follow">';
}
}
add_action('wp_head','prevent_index_tag');
?>

2️⃣ Canonical URLs لتجنب المحتوى المكرر

<link rel="canonical" href="https://example.com/صفحة-أصلية">

القسم 8: أمثلة أكواد ضخمة إضافية للتقنية

1️⃣ Sitemap للفئات

<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$categories = get_categories();
foreach($categories as $cat){
echo '<url>';
echo '<loc>'.get_category_link($cat->term_id).'</loc>';
echo '<changefreq>weekly</changefreq>';
echo '</url>';
}
echo '</urlset>';
?>

2️⃣ تحسين الروابط الداخلية ديناميكيًا

<?php
function auto_internal_links($content){
$keywords = array(
'Technical SEO' => '/seo/technical-seo',
'WordPress SEO' => '/seo/wordpress'
);
foreach($keywords as $key => $link){
$content = preg_replace('/\b'.preg_quote($key,'/').'\b/i','<a href="'.$link.'">'.$key.'</a>',$content);
}
return $content;
}
add_filter('the_content','auto_internal_links');
?>

3️⃣ Lazy Load للفيديو

<iframe class="lazy" data-src="https://www.youtube.com/embed/VIDEOID" width="560" height="315" frameborder="0"></iframe>
<script>
document.addEventListener("DOMContentLoaded",function(){
var iframes = document.querySelectorAll("iframe.lazy");
iframes.forEach(function(iframe){
iframe.src = iframe.getAttribute("data-src");
});
});
</script>

💡 نصيحة تقنية سرية:

  • كل هذه الأكواد تسريع الزحف، تحسين الفهرسة، وتجنب المشاكل التقنية.
  • دمج Structured Data + Canonical + Sitemap + Lazy Load + Responsive يعطي أفضل نتائج SEO تقنية.