Code Monkey home page Code Monkey logo

seotamic's Introduction

PRO Version: If you are having issues with the license, make sure to add 'cnj/seotamic' => 'pro' in the config/statamic/editions.php addons array.

Seotamic - Statamic SEO Addon

Statamic v5 only. For Statamic v4 use the 4.* releases and for Statamic v3 use the 3.* releases. Automatically adds a SEO tab to all your collection entries where you can fine tune SEO for every entry. Works perfectly with Antlers, Blade and in headless mode (PRO edition) with the Statamic REST API or GraphQL integration out of the box.

Quick Antlers usage sample

{{ seotamic }}

Generates the whole array of SEO settings:

<title>My Page Title</title>
<meta name="description" content="SEO friendly description" />
<link rel="canonical" href="https://mysite.com/page" />
<meta property="og:url" content="https://mysite.com/page" />
<meta property="og:site_name" content="Site name" />
<meta property="og:title" content="My Page Title" />
<meta property="og:description" content="SEO friendly description" />
<meta property="og:image" content="https://mysite.com/img/og.jpg" />
...

Version 5 changes

Seotamic v5.* is compatible with Statamic v5.0+.

Version 4.1 changes

Seotamic v4.1 is a minor update that adds related meta tags. The related meta tags are used to link to other pages that are related to the current page in a multisite scenario. They are available as tags and can be used in the Antlers or Blade templates. In the PRO query mode, the related meta tags are also available in the REST API and GraphQL.

Version 4 changes

Statamic v4 compatibility. Some internal functions were changed due to how blueprints work in Statamic v4. This release breaks compatibility with Statamic v3. Upgrade to Statamic v4 before upgrading to this version. Upgrade path from SEOtamic v2 is still the same.

Version 3 changes

Version 3 has breaking changes. If you update from version 1 or 2, your global settings will not be transfered. The data layout is a bit different and so is the data on specific entries.

The string tags were changed to arrays so to access the data you need to use the :meta or :social prefixes. For example {{ seotamic:title }} becomes {{ seotamic:meta:title }}.

Migration from version 2

If you are migrating from version 2, you can use the following command to migrate your data:

php artisan seotamic:migrate

This will migrate your global settings and all the entries. It will also remove the old fields from the entries. Make sure to backup your data before running the command.

Installation

Include the package with composer:

composer require cnj/seotamic

The package requires Laravel 9+ and PHP 8.1+. It will auto register.

The SEO & Social section tab will appear on all collection entries automatically.

Configuration (optional)

You can override the default options by publishing the configuration:

php artisan vendor:publish --provider="Cnj\Seotamic\ServiceProvider" --tag=config

This will copy the default config file to `config/seotamic.php'.

If you need to change the default assets container, make sure to apply the change in the Blueprints as well.

Usage

Usage is fairly simple and straight forward. You can visit the global Settings by following the Seotamic link on the navigation in the CP. Make sure to follow the instructions on each field.

Meta preview

After this you can fine tune the output of each collection entry by editing the SEO settings under the entry's SEO tab. From version 3 you can also preview the output of the meta and social settings. The previews should give an accurate representation of the output.

Social preview

Antlers

There are several antler tags available, the easiest is to just include the do everything base tag in the head of your layout:

{{ seotamic }}

If you need more control you can manually get each part of the output by using:

{{ seotamic:meta:title }}
{{ seotamic:meta:description }}
{{ seotamic:meta:canonical }}
{{ seotamic:meta:robots }}
{{ seotamic:meta:related }}

This will return strings, so you need to wrap them in the appropriate tags, ie:

<title>{{ seotamic:meta:title }}</title>

Social ones will still return everything with these tags (the general one returns this as well)

{{ seotamic:og }}
{{ seotamic:twitter }}

If you need more control you can manually get each part of the output by using:

{{ seotamic:social:title }}
{{ seotamic:social:description }}
{{ seotamic:social:image }}
{{ seotamic:social:site_name }}

This will return strings, so you need to wrap them in the appropriate tags.

Blade

Similarly to the Antlers usage, you can use the same tags using Blade:

{!! Statamic::tag('seotamic')->context(get_defined_vars()) !!}

It works similary to the Antlers tags, so you can use single values as well.

Headless (PRO)

Headless use is straightforward. If using the REST API or GraphQL, the entry will include three Seotamic fields: seotamic_meta, seotamic_social with the prefilled SEO data.

You can also set the base canonical url in the config file by setting a value for headless_mode. The default value is false, but setting it to https://mydomain.com will change all canonical urls. The images will NOT use this base url, as they are still served from Statamic.

Headless usage is supported only for the PRO version.

Sitemap (PRO)

Sitemap is autogenerated under the /sitemap.xml url if the sitemap config options are set to true (default).

Sitemap is supported only for the PRO version.

Dynamic OG Image injection

In projects where you want the OG Image to be dynamic, for now you can use this ViewModel and inject it to your collection in order to dynamically assign the OG Image.

<?php

namespace App\ViewModels;

use Statamic\View\ViewModel;

class OgImage extends ViewModel
{
    public function data(): array
    {
        $social = $this->cascade->get('seotamic_social');

        if ($social) {
          return [ ...$social, 'image' => 'https://myimageurl.com/image.jpg', ];
        }

        return [];
    }
}

In the example above we use a hardcoded image url which you can change to suit your usecase. Then in your collections you just have to inject the ViewModel.

title: Posts
inject:
  view_model: App\ViewModels\OgImage

Credits

This package was built by CNJ Digital.

Version 3, 4 and 5 License

Version 3 and 4 are a commercial addon for Statamic. It is open source but not free to use. You can purchase a license at Statamic Marketplace.

Version 2 and 1 License

Version 2 and 1 were licensed under the MIT License.

seotamic's People

Contributors

martink635 avatar dependabot[bot] avatar arcs- avatar ryanmitchell avatar jmartsch avatar lokmanm avatar giochocolatebro avatar beatwiz avatar humni avatar heywhy avatar

Stargazers

Maksym Storchak avatar  avatar  avatar Lukas avatar AboveWallStreet avatar Hannah Chartier avatar Christian Wyrwas avatar Christopher Zavatchen avatar Samuel De Backer avatar Connor Leech avatar Francesco Mugnai avatar Chumang avatar Holger avatar Vaggelis Yfantis avatar  avatar Craig Smith avatar  avatar Anu Gupta avatar  avatar  avatar

Watchers

 avatar James Cloos avatar Joshua Blum avatar tolawho avatar

seotamic's Issues

Migration v2 to v3 fails

Hi, trying to update from v2 to v3, but it fails

$ php artisan seotamic:migrate
Migrating SEOtamic data from v2 to v3

Make sure you have a backup of your data before you continue!

Do you want to continue? (yes/no) [yes]:

yes

  1. Migrating blueprints…

    RuntimeException

Statamic\Eloquent\Fields\Exception

at vendor/laravel/framework/src/Illuminate/Support/helpers.php:330
326▕ if (is_string($exception) && class_exists($exception)) {
327▕ $exception = new $exception(...$parameters);
328▕ }
329▕
➜ 330▕ throw is_string($exception) ? new RuntimeException($exception) : $exception;
331▕ }
332▕
333▕ return $condition;
334▕ }

  +12 vendor frames 

13 [internal]:0
Cnj\Seotamic\Commands\MigrateCommand::Cnj\Seotamic\Commands{closure}(Object(Statamic\Eloquent\Collections\Collection))

  +17 vendor frames 

31 artisan:35
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
$

Asset Container [assets] not found

  1. I installed this plugin, and then clicking on pages in the control panel gave me an Asset Container [assets] not found error as did clicking on the Seotamic settings.
  2. I published the config and changed the default asset container to main which is what I have on this site.
  3. This fixed the problem when clicking on the Seotamic settings, but did not fix the problem when clicking on pages.

Ensuring I have a container called “assets” fixes this problem, but there are two issues here:

  1. The plugin shouldn’t depend on having an asset container of a specific name in the config, and
  2. Even after changing that name, there is something in the plugin that is still looking for it by that name

Use storage API instead of relative asset paths

Seotamic currently uses relative asset paths, this does not work well with the filesystem Statamic uses. While it is already not recommended to concatenate the path of assets within the frontend, this approach breaks entirely if assets are on a different Server (e.g. on a S3 driver).

So instead of using url($asset); with should use Storage::disk(config('seotamic.container'))->url($asset);. I made this as a draft here: https://github.com/arcs-/seotamic/tree/storage-api, however, I'm myself not well versed on this. Could someone look further into this?

Copy config issue

Got asset container error as my asset container was named images.

Tried

php artisan vendor:publish --provider="cnj/seotamic" --tag=config
Unable to locate publishable resources.
Publishing complete.

In the end just copied the file manually into config directory to fix, but thought should flag up this problem. Thanks for the great SEO addon!

Upgrade breaks things

Running Landtamic which come with SEOtamic 2.

After purchasing a license and upgrading to beta 3 the SEO tags are no longer rendered. Any idea where to look? This looks quite messy...

Title pre and append not working

Nothing is added before or after the title on any pages.

Both title_prepend and title_append have content in the content .yaml file.

Custom title / description not outputting

When using the Custom Meta Title and other custom fields, they are not outputting to the html template.

I think this started happening on Statamic 3 Beta 32.

Thanks, I really appreciate you putting this add-on out while we wait for the official ones!

seotamic v5.0@beta Issue fetching with GraphQL

cnj/seotamic v5.0@beta
statamic/cms v^5.0
Headless with GraphQL

We're encountering a problem while fetching data from Seotamic using GraphQL:

query MyQuery {
  entry(uri: "/") {
    title
    ... on Entry_Pages_Page {
      title
      seotamic_meta
    }
  }
}

We received the following debugMessage:

"debugMessage": "Expected a value of type String but received: {"title":"Startseite Baryon AG","description":"Als unabh\u00e4ngiges, erfahrenes Unternehmen spezialisieren wir uns auf Verm\u00f6gensverwaltung sowie Steuer-, Unternehmens- und Rechtsberatung.","canonical":"http:\/\/localhost:3000\/","robots":"","related":[{"lang":"en","href":"http:\/\/localhost:3000\/en"}]}. String cannot represent value: {"title":"Startseite Baryon AG","description":"Als unabh\u00e4ngiges, erfahrenes Unternehmen spezialisieren wir uns auf Verm\u00f6gensverwaltung sowie Steuer-, Unternehmens- und Rechtsberatung.","canonical":"http:\/\/localhost:3000\/","robots":"","related":[{"lang":"en","href":"http:\/\/localhost:3000\/en"}]}"

Based on my understanding, seotamic_meta should have a subselection like this:

seotamic_meta {
  canonical
  description
  robots
  title
}

However, this results in the following message: "Field 'seotamic_meta' of type 'String' must not have a sub-selection."

Is this a bug, or am I missing some settings? Thank you for your help.

Statamic 4 upgrade issue

I'm getting a compatibility issue when trying to update from Statamic V3 to V4. Is v3.0.9 compatible with Statamic 4?

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires cnj/seotamic 3.0.9 -> satisfiable by cnj/seotamic[v3.0.9].
    - cnj/seotamic v3.0.9 requires statamic/cms ^3.3.0 -> found statamic/cms[v3.3.0-beta.1, ..., 3.4.x-dev] but it conflicts with your root composer.json require (^4.1).

License not working with version 3

I purchased a Seotamic Lite license on 2023-02-16 05:08:32:
image

This license doesn't appear to be working with version 3. Why is that the case?

memory allocation problem during the sitemap generation

We purchased the SEOtamic PRO license to be able to generate the sitemap on our website.

When attempting to access the /sitemap.xml, PHP FastCGI throws a 500 error with the following message:

2023/10/24 13:23:52 [error] 4171854#4171854: *65937 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in 

/home/myuser/mydomain.com/vendor/symfony/yaml/Parser.php on line 107PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in 

/home/myuser/mydomain.com/vendor/symfony/error-handler/Error/FatalError.php on line 1" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: mydomain.com, request: "GET /sitemap.xml HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.1-fpm-myuser.sock:", host: "mydomain.com"

We resolved this issue by increasing the memory limit. However, I also noticed that there isn't any caching logic to store the sitemap content.

Each request to sitemap.xml triggers the regeneration of the sitemap.

The final sitemap.xml size is 448Kb.

Is there a feature available to save the sitemap.xml into a file, thus avoiding regeneration with each request?

Got error afrer install

Symfony\Component\Routing\Exception\RouteNotFoundException
Route [statamic.cp.cnj.seotamic.index] not defined. (View: /Users/vid/code/g/vendor/statamic/cms/resources/views/layout.blade.php)

php: 8.1.2
statamic: 3.2.33

Seotamic not working when Statamic Entry class is extended

We re-bind some of statamics content classes, like referred to in the documentation: https://statamic.dev/extending/repositories#custom-data-classes

Seotamic checks class types with get_class. This outputs a string of the current class. This fails because it's not this exact class, just an instance of it.

 if (get_class($this->field->parent()) === "Statamic\Entries\Entry") {

If we would use instanceof instead, everything would continue to work as expected but you'll be able to still extend Statamics classes.

if ($this->field->parent() instanceof \Statamic\Entries\Entry) {

Empty tags when using Blade

Not sure if you are planning to support Blade but I just tried it out in my Blade layouts and there's no data.

image

image

Bug: Protected Pages appear in the Sitemap

When you protect a page (by any means, defined by Statamic here: https://statamic.dev/protecting-content#protecting-an-entry) these entries still exist in the sitemap.

These entries shouldn't appear in the sitemap, as the sitemap should only include unprotected collections and entities (as Google will show you indexing errors if 403 response pages exist in your sitemap).

Working on a PR to resolve this, it should be relatively simple to fix.

Replication Steps A:

  1. Create a Collection which includes:
    inject:
      protect: logged_in
    
  2. Create an entry in that collection
  3. Visit sitemap.xml, and you will see the entry for that collection (expected: you shouldn't see it in the sitemap)

Replication Steps B:

  1. Create an normal, unprotected collection
  2. Create a protected entry in that collection by adding the following:
      protect: logged_in
    
  3. Visit sitemap.xml, and you will see the entry (expected: you shouldn't see it in the sitemap)

All seo content the same

Progress from: #42 (comment)

All SEO tags are now duplicated when running:

php please ssg:generate

...results in every generated page having the same:
title tag
description
og:type
og:title
twitter:card
twitter:title

Any ideas?

A.

Still not working after ugrade

See issue #26 for the details.

summary

After the upgrade to version 3 and running the upgrade script, the seo-related tags are not rendered in the final html, even though the correct tag exists in the antlers layout file. With version 2 this was working fine.

Titles in YAML

This might be a misconfiguration on my part, but it seems that if a page has title defined in the template/md file, it’s not outputted.

For instance, a search page in /resources/views/search.antlers.html:

---
title: 'Search'
---
<main class="container search-page" id="content" role="main">
  <h1>Search</h1>

  {{ partial:search-form }}
  
</main>

The title isn’t outputted into the <title> tag.

Environment
Statamic 3.0.30 Pro
Laravel 7.29.2
PHP 7.4.11
cnj/seotamic 2.0.2
statamic/migrator dev-master

Hreflang takes the site handle, not the site name or language value

The canonical language hreflang value uses the site handle, by default, Statamic name the first site 'default'. This is tricky to adjust afterwards or optimize, because it means renaming all content folders (or database handle)

` 'sites' => [

    'default' => [
        'name' => 'ACME USA',
        'locale' => 'en_US',
        'url' => '/en/',
    ],

    'fr' => [
        'name' => 'ACME CANADA',
        'locale' => 'fr_CA',
        'url' => '/fr/',
    ],

    'zh' => [
        'name' => 'ACME 中文',
        'locale' => 'zh-CN',
        'url' => '/zh/',
    ],

],`

It should use the locale, or have a configuration other site param to use.

<link rel="alternate" hreflang="default" href="https://mysiste.com/en" />

"unlicensed" message under 2.1.0

When using 2.1.0 of this add-on, Statamic lists it as "unlicensed" and warns that "This site is using commercial addons. Please purchase appropriate licenses." Based on the readme, it sounds like 2.1.0 should be MIT licensed and not require the purchase of a commercial license to use in production. Would you be able to confirm?

image

Title tag not being populated since update

...have I missed a step?

All title tags are now empty and are not being repopulated - but they have been set.

Theme template has:
{{ seotamic }}

<link rel="stylesheet" href="{{ mix src='css/tailwind.css' }}">

Rendered content has:
<title></title> <meta name="description" content=""><link rel="stylesheet" href="[/css/tailwind.css?id=1d35895506f4ec8afc966b015ea429e7](http://localhost:8000/css/tailwind.css?id=1d35895506f4ec8afc966b015ea429e7)">

Migration error

Hi!

I use "statamic/cms": "^4.0", with "cnj/seotamic": "^4.0", but i had v2 version about your addon before. I wanted to upgrade and I faced with an error: Call to undefined method Statamic\Fields\Blueprint::hasSection()

I started debugging and it looks like in statamic v4 this method is removed. There are new methods instead of hasSection() becomes to hasTab() and removeSection() becomes removeTab(). Please take a look about it!

Unable to access after getting pro

Visiting plugin page on CP results this error;
Cnj\Seotamic\FieldTypes\SeotamicSocialPreview::getImageUrl(): Return value must be of type string, null returned

'cnj/seotamic' => 'pro', added.

Error: Signature is missing (for og:image)

Hi there, I am using this plug in populate images. It's working great on the backend but when it injects the og:image tag it links to an image path that does not exist.

Screen Shot 2021-09-11 at 10 23 29 PM

Following that URL I get an error: Impossible to create the root directory "/var/www/html/storage/statamic/glide/containers/images/terminator-ai.jpeg".

Screen Shot 2021-09-11 at 10 23 48 PM

Is there a way I can configure the path so that the og:image links to a real image instead of trying to create a directory?

The image is looking fine on the Statamic backend :)

Screen Shot 2021-09-11 at 10 24 58 PM

This is an example of a live post that it's happening for.

This is the path to the actual image I'd like to use: https://www.employbl.com/assets/terminator-ai.jpeg

If I change the seotamic config to 'container' => 'assets', then no image shows up in the og:image tag.

Settings not saved on version control

Hello and thank you for creating this package for v3!

image

When I locally make changes here, those will not be committed to version control. Is there any workarounds to this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.