diff --git a/app/Http/Controllers/SitemapController.php b/app/Http/Controllers/SitemapController.php index ebbaf87..6dfc767 100644 --- a/app/Http/Controllers/SitemapController.php +++ b/app/Http/Controllers/SitemapController.php @@ -12,24 +12,50 @@ class SitemapController extends Controller public function index(): Response { $urls = []; + $activeLanguages = []; + if (class_exists(\App\Models\Language::class)) { + $activeLanguages = \App\Models\Language::where('is_active', true)->get(); + } + + $getAlternates = function (string $baseUrl) use ($activeLanguages) { + $alternates = []; + foreach ($activeLanguages as $lang) { + $connector = str_contains($baseUrl, '?') ? '&' : '?'; + $alternates[] = [ + 'hreflang' => $lang->code, + 'href' => $baseUrl . $connector . 'locale=' . $lang->code, + ]; + } + $alternates[] = [ + 'hreflang' => 'x-default', + 'href' => $baseUrl, + ]; + return $alternates; + }; // 1. Static & Main Pages + $homeUrl = url('/'); $urls[] = [ - 'loc' => url('/'), + 'loc' => $homeUrl, + 'alternates' => $getAlternates($homeUrl), 'lastmod' => now()->startOfDay()->toAtomString(), 'changefreq' => 'daily', 'priority' => '1.0', ]; + $blogIndexUrl = route('blog.index'); $urls[] = [ - 'loc' => route('blog.index'), + 'loc' => $blogIndexUrl, + 'alternates' => $getAlternates($blogIndexUrl), 'lastmod' => now()->startOfDay()->toAtomString(), 'changefreq' => 'weekly', 'priority' => '0.8', ]; + $careerIndexUrl = route('career.index'); $urls[] = [ - 'loc' => route('career.index'), + 'loc' => $careerIndexUrl, + 'alternates' => $getAlternates($careerIndexUrl), 'lastmod' => now()->startOfMonth()->toAtomString(), 'changefreq' => 'monthly', 'priority' => '0.5', @@ -40,8 +66,10 @@ class SitemapController extends Controller ->where('is_homepage', false) ->get(); foreach ($pages as $page) { + $pageUrl = url($page->slug); $urls[] = [ - 'loc' => url($page->slug), + 'loc' => $pageUrl, + 'alternates' => $getAlternates($pageUrl), 'lastmod' => $page->updated_at->toAtomString(), 'changefreq' => 'weekly', 'priority' => '0.7', @@ -52,8 +80,10 @@ class SitemapController extends Controller if (class_exists(Blog::class)) { $posts = Blog::published()->get(); foreach ($posts as $post) { + $postUrl = route('blog.show', $post->slug); $urls[] = [ - 'loc' => route('blog.show', $post->slug), + 'loc' => $postUrl, + 'alternates' => $getAlternates($postUrl), 'lastmod' => $post->updated_at->toAtomString(), 'changefreq' => 'weekly', 'priority' => '0.6', @@ -65,8 +95,10 @@ class SitemapController extends Controller if (class_exists(Product::class)) { $products = Product::where('is_active', true)->get(); foreach ($products as $product) { + $productUrl = route('products.show', $product->slug); $urls[] = [ - 'loc' => route('products.show', $product->slug), + 'loc' => $productUrl, + 'alternates' => $getAlternates($productUrl), 'lastmod' => $product->updated_at->toAtomString(), 'changefreq' => 'weekly', 'priority' => '0.7', diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php index 432bc9d..6a1e4dc 100644 --- a/app/Http/Middleware/SetLocale.php +++ b/app/Http/Middleware/SetLocale.php @@ -16,10 +16,25 @@ class SetLocale */ public function handle(Request $request, Closure $next): Response { - // Session'dan locale'i al, yoksa varsayılan dil kodunu kullan - $locale = session('locale'); + // Aktif dilleri veritabanından kontrol et + if (function_exists('available_language_codes')) { + $availableLocales = available_language_codes(); + } else { + $availableLocales = ['tr', 'en', 'de', 'ar', 'se', 'ru']; + } + + // Query parametresinden al, yoksa session'dan al + $queryLocale = $request->query('locale') ?? $request->query('lang'); + $locale = null; + + if ($queryLocale && in_array($queryLocale, $availableLocales)) { + $locale = $queryLocale; + session(['locale' => $locale]); + } else { + $locale = session('locale'); + } - // Eğer session'da locale yoksa, varsayılan dil kodunu kullan + // Eğer locale hala atanmadıysa varsayılan dil kodunu kullan if (!$locale) { if (function_exists('default_language_code')) { $locale = default_language_code(); @@ -28,14 +43,7 @@ class SetLocale } } - // Aktif dilleri veritabanından kontrol et - if (function_exists('available_language_codes')) { - $availableLocales = available_language_codes(); - } else { - $availableLocales = ['tr', 'en']; - } - - // Locale'i aktif diller arasında kontrol et + // Locale'i aktif diller arasında kontrol et ve ata if (in_array($locale, $availableLocales)) { App::setLocale($locale); } else { diff --git a/app/Support/StructuredData.php b/app/Support/StructuredData.php index 312fa01..f188c3d 100644 --- a/app/Support/StructuredData.php +++ b/app/Support/StructuredData.php @@ -63,10 +63,42 @@ abstract class StructuredData $siteName = static::siteName(); $node = [ - '@type' => 'Organization', + '@type' => 'ProfessionalService', '@id' => $siteUrl . '#organization', 'name' => $siteName, 'url' => $siteUrl, + 'priceRange' => '$$', + 'geo' => [ + '@type' => 'GeoCoordinates', + 'latitude' => 37.025704, + 'longitude' => 37.296559, + ], + 'areaServed' => [ + [ + '@type' => 'AdministrativeArea', + 'name' => 'Gaziantep', + ], + [ + '@type' => 'Country', + 'name' => 'Turkey', + ] + ], + 'knowsAbout' => [ + 'Yazılım Geliştirme', + 'Web Tasarım', + 'Mobil Uygulama Geliştirme', + 'E-Ticaret Sistemleri', + 'SEO Danışmanlığı', + 'Gaziantep Yazılım Şirketleri' + ], + 'openingHoursSpecification' => [ + [ + '@type' => 'OpeningHoursSpecification', + 'dayOfWeek' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], + 'opens' => '09:00', + 'closes' => '18:00', + ] + ] ]; $logo = setting('site_logo'); @@ -93,6 +125,10 @@ abstract class StructuredData $node['address'] = [ '@type' => 'PostalAddress', 'streetAddress' => $address, + 'addressLocality' => 'Şahinbey', + 'addressRegion' => 'Gaziantep', + 'postalCode' => '27190', + 'addressCountry' => 'TR', ]; } diff --git a/public/googlef1M6GQLxVA5g7IaVY6kMQCoIrgADR6HjrOZu79CrXYc.html b/public/googlef1M6GQLxVA5g7IaVY6kMQCoIrgADR6HjrOZu79CrXYc.html new file mode 100644 index 0000000..0070b0b --- /dev/null +++ b/public/googlef1M6GQLxVA5g7IaVY6kMQCoIrgADR6HjrOZu79CrXYc.html @@ -0,0 +1 @@ +google-site-verification: googlef1M6GQLxVA5g7IaVY6kMQCoIrgADR6HjrOZu79CrXYc.html diff --git a/public/robots.txt b/public/robots.txt index eb05362..3479ec3 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,2 +1,6 @@ User-agent: * -Disallow: +Allow: / +Disallow: /admin/ +Disallow: /stajyer/admin/ + +Sitemap: https://truncgil.com/sitemap.xml diff --git a/resources/views/layouts/site.blade.php b/resources/views/layouts/site.blade.php index f822a2b..e74bad9 100644 --- a/resources/views/layouts/site.blade.php +++ b/resources/views/layouts/site.blade.php @@ -17,16 +17,35 @@ $favicon_path = setting('site_favicon'); } @endphp @php - $seo_canonical = $meta['canonical'] ?? url()->current(); + $seo_canonical = $meta['canonical'] ?? null; + if (!$seo_canonical) { + $seo_canonical = url()->current(); + $localeQuery = request()->query('locale') ?? request()->query('lang'); + if ($localeQuery && function_exists('available_language_codes') && in_array($localeQuery, available_language_codes())) { + $seo_canonical .= '?locale=' . $localeQuery; + } + } $seo_robots = $meta['robots'] ?? 'index, follow'; $seo_og_type = $meta['og_type'] ?? 'website'; $seo_og_locale = str_replace('_', '-', $meta['locale'] ?? app()->getLocale()); + + $activeLanguages = class_exists(\App\Models\Language::class) + ? \App\Models\Language::where('is_active', true)->get() + : collect([]); + $currentUrl = url()->current(); @endphp {{ $seo_title }} + @foreach($activeLanguages as $lang) + + @endforeach + @if($activeLanguages->count() > 0) + + @endif + diff --git a/resources/views/sitemap.blade.php b/resources/views/sitemap.blade.php index 10045eb..af1b25d 100644 --- a/resources/views/sitemap.blade.php +++ b/resources/views/sitemap.blade.php @@ -1,8 +1,14 @@ {!! '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' !!} - + @foreach($urls as $url) {{ $url['loc'] }} + @if(!empty($url['alternates'])) + @foreach($url['alternates'] as $alt) + + @endforeach + @endif {{ $url['lastmod'] }} {{ $url['changefreq'] }} {{ $url['priority'] }}