Closed sunscreem closed 7 months ago
What does your sites.php
config look like? And what language are you expecting?
Hey @aerni - I think you just found my issue straight away, I wasn't aware there is a language setting in that file! Apologies if I'm wasting your time.
The language I want to use on the site is just en
(or en_GB
) if just en
isn't valid?
Maybe you can suggest the correct config settings?
Here's my config/statamic/sites.php
:
return [
/*
|--------------------------------------------------------------------------
| Sites
|--------------------------------------------------------------------------
|
| Each site should have root URL that is either relative or absolute. Sites
| are typically used for localization (eg. English/French) but may also
| be used for related content (eg. different franchise locations).
|
*/
'sites' => [
'default' => [
'name' => config('app.name'),
'locale' => 'en_US',
'url' => '/',
],
],
];
Also - here's the relevant part of my config/app.php
:
return [
// other stuff
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_GB',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
etc
You should use the full locale like en_GB
.
Hey @aerni - I'm still unable to prevent the alternate showing :(
In my config/app.php:
'locale' => 'en_GB',
'fallback_locale' => 'en',
In my config/statamic/sites.php:
'sites' => [
'default' => [
'name' => config('app.name'),
'locale' => 'en_GB',
'url' => '/',
],
],
However I'm still getting this in the output html:
<html>
<body>
<!doctype html>
<html lang="en">
<!-- stuff -->
<link rel='alternate' href="http://lcs.sunscreem.xyz" hreflang="en-GB" >
That's correct. As far as I know, it shouldn't make a difference if the alternate link is there, even if it's the only language the site exists in. Is there a particular reason you don't want the link in there?
Thank @aerni - I received the following from a client today, which I assume has come from their SEO people:
The following pages have hreflang conflicts:
[list of pages on the site]
They also sent this (you can ignore the first paragraph as it's not a multilingual site):
If you're running a multilingual website, it is necessary to help users from other countries find your content in the language that is most appropriate for them. This is where the hreflang (rel="alternate" hreflang="x") attribute comes in handy. This attribute helps search engines understand which page should be shown to visitors based on their location. It is very important to properly synchronize your hreflang attributes within your page's source code, otherwise you may experience unexpected search engine behavior.
If your page doesn’t contain a self-referencing hreflang in its set of hreflang attributes, those attributes may be ignored or interpreted incorrectly. Include this page’s URL and language code in your set of hreflang attributes.
To fix this issue, the tool recommends the following:
To avoid any conflicts, we recommend that you review your hreflang attributes within your page's source code and fix any of the following issues:
From what I understand in this message, everything works as expected.
If your page doesn’t contain a self-referencing hreflang in its set of hreflang attributes, those attributes may be ignored or interpreted incorrectly. Include this page’s URL and language code in your set of hreflang attributes.
The page DOES include a self-referencing hreflang. So I don't understand why you are trying to remove it.
@aerni I think I've suitably embarrassed myself here. You are absolutely correct. I had assumed the issue was they wanted the alternate removed! I don't know what to say. I'm sorry for wasting your time.
No worries. Glad you got it sorted. Enjoy the rest of your day!
When I look at the tags that Advanced SEO is adding to my page, it's adding a
<link rel='alternate'
tag with the wrong language:Note that the alternative page has a different language suggestion of en-US, which isn't correct as the site is not using en-US.
I've been through all the config settings, and all changes made during the setup in the control panel and can't seem to figure this one out.