パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.0.10

seo

Web上でSEO(メタ、bodyタグ)サポートを有効にするためのFlutterパッケージ。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.2万
いいね数
142
Pub ポイント
140

パッケージをインストール

flutter pub add seo

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

seo パッケージは、Web アプリケーションの SEO 機能を強化するために設計された Flutter プラグインです。メタタグやボディ属性を動的に管理できるようにすることで、開発者が Dart コードからタイトル、説明、Open Graph タグ、その他の SEO 関連コンテンツを直接設定できます。これにより、検索エンジンがウェブページを適切にインデックス化でき、可視性とランキングが向上します。このパッケージは Flutter の Web プラットフォームとシームレスに統合され、サーバーサイドレンダリングの考慮事項もサポートしています。手動で HTML を編集せずに豊富なメタデータ制御が必要なアプリには特に役立ちます。

用途

  • 動的メタタグの更新
  • 改善された検索エンジンインデクシング
  • ソーシャルメディア共有最適化
  • シングルページアプリケーションのSEO
  • ルートに基づくコンテンツのパーソナライズ
  • サーバーサイドレンダリングの互換性

主な機能

  • メタタグの管理を簡単に
  • Open Graph および Twitter カードのサポート
  • 動的なタイトルおよび説明の変更
  • クロスプラットフォームWeb対応
  • 最小限のボイラープレート
  • Flutter ルーティングとの統合

適している対象

  • Web専用のFlutterアプリ
  • SEOに焦点を当てたWebアプリケーション
  • 動的コンテンツを持つアプリ
  • 検索表示の可視性を最優先とする開発者
  • ソーシャルメディアメタデータを必要とするプロジェクト
  • クライアントサイドルーティングを使用するアプリ

注意事項

  • モバイルプラットフォーム(Android/iOS)には対応していません
  • マルチルートのシナリオでは慎重な取り扱いが必要です
  • Webプラットフォーム機能に限定
  • 完全な SSR フレームワークを置き換えるものではありません
  • 高度なSEOには手動設定が必要です
  • 適切なページ構造と併用すると最適です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

flutter_seo

pub package

Flutter package for enabling SEO (meta, body tag) support on Web. The package listens to widget tree changes and converts Seo.text(...), Seo.image(...), Seo.link(...), Seo.head(...) widgets into html document tree. View Demo

 

Getting Started

To use this plugin, add seo as a dependency in your pubspec.yaml file.

dependencies:
  seo: ^0.0.10

Use usePathUrlStrategy() to ensure that Google recognizes each URL as a distinct page. Failure to do so may result in Google perceiving all URLs as the same page. For additional details, refer to this video.

void main() {
  usePathUrlStrategy();
  runApp(App());
}

 
Wrap your app within SeoController which will handle listening to widget tree changes and updating the html document tree. In case your app has authorization and user is logged in you can disable the controller by enabled: false as it's redundant to update the html document tree at that state.

import 'package:seo/seo.dart';

void main() {
  usePathUrlStrategy();
  runApp(const App());
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return SeoController(
      enabled: true,
      tree: WidgetTree(context: context),
      child: MaterialApp(...),
    );
  }
}

 
There's two available SeoTree implementations:

  • WidgetTree (recommended) - based on traversing widget tree, while it's bit slower than SemanticsTree it's production ready and doesn't have any blocking Flutter SDK issues.
  • SemanticsTree (experimental) - based on traversing semantic data node tree. Does traverse the tree faster but doesn't support Seo.head(...), Seo.text(style: ...), Seo.link(rel: ...), Seo.html(html: ...)

 

Sample Usage

You should wrap all your SEO required widgets accordingly within Seo.text(...), Seo.image(...), Seo.link(...) and SEO required pages within Seo.head(...). From personal experience it's more comfortable to create custom AppText, AppImage, AppLink, AppHead base widgets and use those in the project.

Text
Seo.text(
  text: 'Some text',
  child: ...,
); // converts to: <p>Some text</p>

Seo.text(
  text: 'Some text',
  style: TextTagStyle.h1,
  child: ...,
); // converts to: <h1>Some text</h1>
Image
Seo.image(
  src: 'http://www.example.com/image.jpg',
  alt: 'Some example image',
  child: ...,
); // converts to: <img src="http://www.example.com/image.jpg" alt="Some example image"/>
Link
Seo.link(
  href: 'http://www.example.com',
  anchor: 'Some example',
  rel: 'nofollow', (optional)
  child: ...,
); // converts to: <a href="http://www.example.com" rel="nofollow"><p>Some example</p></a>
Html
Seo.html(
  html: '<div>Some raw html</div>',
  child: ...,
); // converts to: <div>Some raw html</div>
Head
Seo.head(
  tags: [
    MetaTag(name: 'title', content: 'Flutter SEO Example'),
    LinkTag(rel: 'canonical', href: 'http://www.example.com'),
  ],
  child: ...,
); // converts to: <meta name="title" content="Flutter SEO Example"><link rel="canonical" href="http://www.example.com" />

Warning: Open Graph (og:title, og:description, etc.) and Twitter Card (twitter:title, twitter:description, etc.) will not work. Read more.

 

Tips

Supporting Open Graph, Twitter Card tags

Facebook, Twitter, etc. simply load index.html and don't execute any JavaScript that webpage contains so we're not able to change meta tags within Dart code. The proposed solution is to create simple Server-Side Rendering which would add Open Graph, Twitter Card tags within index.html before returning it to Client.

 

Demo

View demo here: https://flutter-seo.netlify.app

PageSpeed Insights

MobilePerformance ≈56Accessibility 87Best Practices 100SEO 100
DesktopPerformance ≈85Accessibility 88Best Practices 100SEO 100

Google Search

Landing page has been indexed and does appear in Search

Remaining pages have Discovered - currently not indexed status. I am investigating why.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。