krokyze / flutter_seo

Flutter package for SEO support on Web.
MIT License
46 stars 5 forks source link

SEO for Localised pages, is alternate hreflang possible? #29

Closed vinnytwice closed 1 year ago

vinnytwice commented 1 year ago

I'm getting into the process of doing SEO for my Flutter web site and I'm looking into flutter_seo, but I'm not a web dev so I might have gotten the whole process/concetpts wrong. As I've localised content (eg. page title and paragraph) which dynamically changes depending on the System language, where I pick the correct translation from a json file as so:

Text(
                          AppLocalizations.instance
                              .text('About us title 1 desktop'),
                          style: TextStyle(
                              color: Colors.orange,
                              fontSize: 25,
                              fontWeight: FontWeight.bold,
                              height: 1.5),
                          textAlign: TextAlign.left,
                          maxLines: 100,
                        ),
                        SizedBox(
                          height: 20,
                        ),
                        Text(
                          AppLocalizations.instance
                              .text('About us content 1 desktop'),
                          style: TextStyle(
                              color: Colors.white, fontSize: 15, height: 1.5),
                          textAlign: TextAlign.left,
                          maxLines: 100,
                        ),

I saw that the way to make different languages fall under the same page root would be to use alternate links specifying the hreflang property as in

      <head>
        <title>Your Page Title</title>
        <link rel="alternate" hreflang="en" href="https://www.example.com/page1" />
        <link rel="alternate" hreflang="fr" href="https://www.example.com/page1" />
        <!-- Add more hreflang tags for other languages if needed -->
      </head>

Now in your your example, and looking into the docs I don't see any hreflang parameter to be used.

Seo.head(
  tags: [
    MetaTag(name: 'title', content: 'Flutter SEO Example'),
    LinkTag(rel: 'canonical', href: 'http://www.example.com'),
  ],
  child: ...,
);

converting to

<meta name="title" content="Flutter SEO Example">
<link rel="canonical" href="http://www.example.com" />

Is it possible to include it ? Where should the hreflang parameter eventually be specified ? Many thanks

krokyze commented 1 year ago

Hey. I just published new version 0.0.5 with support for hreflang for the link tag. If you notice any issues, feel free to reopen this issue.