搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.10

seo

用於在 Web 上啟用 SEO(meta、body 標籤)支援的 Flutter 套件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.2萬
喜歡數
142
Pub 分數
140

安裝套件

flutter pub add seo

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

seo 套件是一個 Flutter 插件,專為增強 Web 應用程式的 SEO 功能而設計,透過動態管理 meta 標籤和 body 屬性來實現。它允許開發者直接從 Dart 程式碼設定標題、描述、Open Graph 標籤及其他與 SEO 相關的內容。這確保搜尋引擎能正確索引網頁,提升可見度與排名。該套件與 Flutter 的 Web 平台無縫整合,並支援伺服器端渲染的考量。對於需要豐富元資料控制而不需手動修改 HTML 的應用來說,特別實用。

適用情境

  • 動態元標籤更新
  • 改進的搜尋引擎索引
  • 社群媒體分享優化
  • 單頁應用SEO
  • 基於路線的內容個人化
  • 伺服器端渲染相容性

主要特色

  • 輕鬆管理元標籤
  • 支援 Open Graph 和 Twitter 卡片
  • 動態標題和描述變更
  • 跨平台 Web 支援
  • 最小化樣板程式碼
  • 與 Flutter 路由的整合

適合對象

  • 僅限 Web 的 Flutter 應用
  • 面向搜尋引擎優化的Web應用
  • 動態內容的應用程式
  • 重視搜尋可見性的開發者
  • 需要社交媒體元資料的專案
  • 使用客戶端路由的應用程式

使用建議

  • 不適用於行動平台(Android/iOS)
  • 在多路徑場景中需要謹慎處理
  • 僅限網頁平台功能
  • 不取代完整的 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。