Skip to content

Commit

Permalink
Merge branch 'release/3.5.0' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jul 12, 2024
2 parents db5cc85 + 25149a3 commit c324225
Show file tree
Hide file tree
Showing 20 changed files with 280 additions and 276 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/code-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ jobs:
fail-fast: false
matrix:
actions:
-
name: 'PHPStan'
- name: 'PHPStan'
run: composer phpstan
-
name: 'Coding Standards'
run: composer fix-cs
- name: 'Coding Standards'
run: composer check-cs
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SEOmatic Changelog

## 3.5.0 - 2024.07.12
### Added
* Remove queue generated sitemaps, switch to paginated sitemaps to allow them to be rendered at web response time, but still be managable in size

## 3.4.78 - 2024.05.13
### Added
* Added a setting in Plugin Settings -> Tags to specify which site should be used as the `x-default` for `hreflang` tags ([1162](https://github.com/nystudio107/craft-seomatic/issues/1162))
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "3.4.78",
"version": "3.5.0",
"keywords": [
"craft",
"cms",
Expand Down Expand Up @@ -63,7 +63,7 @@
"vlucas/phpdotenv": "^3.0"
},
"scripts": {
"phpstan": "phpstan --ansi --memory-limit=1G",
"phpstan": "phpstan --ansi --memory-limit=2G",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --fix --ansi",
"test": "codecept run unit --coverage-xml"
Expand Down
12 changes: 5 additions & 7 deletions docs/docs/configuring/content-seo.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,19 @@ SEOmatic automatically creates a sitemap index for each of your Site Groups. Thi

Instead of one massive sitemap that must be updated any time anything changes, only the sitemap for the Section, Category Group, or Commerce Product Type will be updated when something changes in it.

Check warning on line 41 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"be updated" may be passive voice

Check warning on line 41 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"only" can weaken meaning

Check warning on line 41 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"be updated" may be passive voice

Additionally, sitemaps are paginated according to the **Sitemap Page Size** setting (which defaults to `500` per page), to allow for a large number of entries in the sitemaps without hurting performance.

Check warning on line 43 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"Additionally" can weaken meaning

Check warning on line 43 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

"are paginated" may be passive voice

Check warning on line 43 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

Avoid using “a large number of”

SEOmatic can automatically include files such as `.pdf`, `.xls`, `.doc` and other indexable file types in Asset fields or Asset fields in matrix or Neo blocks.

In addition, SEOmatic can automatically create [Image sitemaps](https://support.google.com/webmasters/answer/178636?hl=en) and [Video sitemaps](https://developers.google.com/webmasters/videosearch/sitemaps) from images & videos in Asset fields or Asset fields in matrix or Neo blocks.

Check warning on line 47 in docs/docs/configuring/content-seo.md

View workflow job for this annotation

GitHub Actions / build (20.x)

Avoid using “In addition”

Sitemap Indexes are automatically submitted to search engines whenever a new Section, Category Group, or Commerce Product Type is added.

Section Sitemaps are automatically submitted to search engines whenever a new Element in that Section, Category Group, or Commerce Product Type is added.
Search engines no longer allow for sitemap submission via, but rather will re-crawl your sitemaps on a regular basis to find new pages.

### Sitemap Generation

Because XML sitemaps can be time-intensive to generate with a growing number of entries, SEOmatic creates your sitemaps via a queue job and caches the result. The cache is automatically broken whenever something in that sitemap is changed, and a new queue job is created to regenerate it.

If `runQueueAutomatically` is set to `false` in [General Config Settings](https://craftcms.com/docs/3.x/config/config-settings.html#runqueueautomatically) the Queue job to create the sitemap will not be run during the http request for the sitemap. You’ll need to run it manually via whatever means you use to run the Queue.
SEOmatic generates sitemaps on-demmand when requested on the frontend, and then caches the sitemap for future requests so they are fast.

Normally SEOmatic will regenerate the sitemap for a Section, Category Group, or Product any time you save an element. However, if you are importing a large number of elements, or prefer to regenerate the sitemap manually you can set disable the **Regenerate Sitemaps Automatically** option in SEOmatic’s Plugin Settings.
Normally SEOmatic will invalidate the cache for a sitemap for a Section, Category Group, or Product any time you save an element. However, if you prefer to regenerate the sitemap manually you can set disable the **Regenerate Sitemaps Automatically** option in SEOmatic’s Plugin Settings.

![Screenshot of a console running the following command to generate a blog sitemap: `./craft seomatic/sitemap/generate --siteId=1 --handle=blog`](../resources/screenshots/seomatic-sitemap-console-command.png)

Expand Down
1 change: 0 additions & 1 deletion docs/docs/configuring/plugin-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Plugin Settings let you control various SEOmatic settings across all sites/langu
* **Automatic Render Enabled** – Controls whether SEOmatic automatically renders metadata on your pages. If you turn this off, you will need to manually render the metadata via `seomatic.tag.render()`, `seomatic.link.render()`, etc. Selectively disable rendering via Twig with `{% do seomatic.config.renderEnabled(false) %}`.
* **Sitemaps Enabled** – Controls whether SEOmatic will automatically render front-end sitemaps for your site.
* **Regenerate Sitemaps Automatically** – Controls whether sitemaps will automatically be regenerated when entries are saved.
* **Submit Sitemap Changes** – Should sitemaps be submitted to search engines automatically whenever there are changes?
* **Include Homepage in Breadcrumbs** – Should the homepage be included in the generated Breadcrumbs JSON-LD?
* **Manually Set SEOmatic Environment** – If off, SEOmatic will automatically attempt to determine the current environment. Turn this on to manually set the environment.
* **Environment** – The server environment, either `live`, `staging`, or `local`. If `devMode` is on, SEOmatic will override this setting to local Development. This setting controls whether certain things render; for instance only in the `live` production environment will Google Analytics and other tracking tags send analytics data. SEOmatic also automatically sets the `robots` tag to `none` for everything but the `live` production environment.
Expand Down
2 changes: 1 addition & 1 deletion src/base/SitemapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface SitemapInterface
// Constants
// =========================================================================

const GLOBAL_SITEMAP_CACHE_TAG = 'seomatic_sitemap';
const GLOBAL_SITEMAP_CACHE_TAG = 'seomatic_sitemap_v2';
}
35 changes: 26 additions & 9 deletions src/console/controllers/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function actionGenerate()
foreach ($siteIds as $siteId) {
$metaBundles = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId);
Seomatic::$plugin->metaBundles->pruneVestigialMetaBundles($metaBundles);

/** @var MetaBundle $metaBundle */
foreach ($metaBundles as $metaBundle) {
$process = false;
Expand All @@ -97,17 +98,33 @@ public function actionGenerate()
. ', siteId '
. $siteId
. PHP_EOL;
// Generate the sitemap so it is in the cache

$seoElement = Seomatic::$plugin->seoElements->getSeoElementByMetaBundleType($metaBundle->sourceBundleType);
$elementQuery = $seoElement::sitemapElementsQuery($metaBundle);
$pageSize = (int) $metaBundle->metaSitemapVars->sitemapPageSize;
$sitemapLimit = (int) $metaBundle->metaSitemapVars->sitemapLimit;

if (!empty($pageSize)) {
$total = empty($sitemapLimit) ? $elementQuery->count() : min($elementQuery->count(), $sitemapLimit);
$pageCount = ceil($total / $pageSize);
} else {
$pageCount = 1;
}

$site = Craft::$app->getSites()->getSiteById($metaBundle->sourceSiteId);
$sitemap = SitemapTemplate::create();
if ($site) {
$sitemap = SitemapTemplate::create();
$sitemap->render([
'groupId' => $site->groupId,
'siteId' => $metaBundle->sourceSiteId,
'handle' => $metaBundle->sourceHandle,
'type' => $metaBundle->sourceBundleType,
'immediately' => true,
]);
for ($pageNum = 1; $pageNum <= $pageCount; $pageNum++) {
echo sprintf('Generating page %d of %d' . PHP_EOL, $pageNum, $pageCount);
$sitemap->render([
'groupId' => $site->groupId,
'siteId' => $metaBundle->sourceSiteId,
'handle' => $metaBundle->sourceHandle,
'type' => $metaBundle->sourceBundleType,
'page' => $pageNum,
]);
}
// Generate the sitemap so it is in the cache
}

echo '---' . PHP_EOL;
Expand Down
9 changes: 8 additions & 1 deletion src/controllers/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,22 @@ public function actionSitemapEmptyStyles(): Response
*
* @return Response
*/
public function actionSitemap(int $groupId, string $type, string $handle, int $siteId): Response
public function actionSitemap(int $groupId, string $type, string $handle, int $siteId, string $file): Response
{
$page = null;

if (preg_match('/sitemap-p([\d]+)\.xml/i', $file, $matches)) {
$page = $matches[1];
}

$xml = Seomatic::$plugin->sitemaps->renderTemplate(
Sitemaps::SEOMATIC_SITEMAP_CONTAINER,
[
'groupId' => $groupId,
'type' => $type,
'handle' => $handle,
'siteId' => $siteId,
'page' => $page,
]
);
$headers = Craft::$app->response->headers;
Expand Down
Loading

0 comments on commit c324225

Please sign in to comment.