Sitemap generator including newsletters - #476
Conversation
1fa2958 to
af9946b
Compare
670ea76 to
f709c7c
Compare
f709c7c to
072b2d6
Compare
| // Last modified | ||
| $xml->startElement('lastmod'); | ||
| $lastmod = $urlData['lastmod']; | ||
| if ($lastmod instanceof \Carbon\Carbon) { |
There was a problem hiding this comment.
This should be Carbon only (simplify FQDn with use Carbon\Carbon.
There was a problem hiding this comment.
This needs a cron job, doesn't it? Or is the expectation to just run it from time to time?
There was a problem hiding this comment.
It can be either a cron i.e. once per week, per month or manual run after newsletter publish.
Currently it is intended to fix at least current sitemap misleading the search engines that site got last content update 2020-05-17.
| priority: 0.6 | ||
| newsletters: | ||
| # Newsletter articles with language variants | ||
| priority: 0.6 No newline at end of file |
There was a problem hiding this comment.
Missing new line at the end of file.
|
|
||
| return $xml->outputMemory(true); | ||
| } | ||
| } |
There was a problem hiding this comment.
Missing new line at the end of file.
There was a problem hiding this comment.
shouldn't it be added to phpcbf? I may do this in this PR or separately,
There was a problem hiding this comment.
That wouldn't help for the yaml files. Git complains about that the time if you do not add one...
| "ext-pdo": "*", | ||
| "ext-pdo_mysql": "*", | ||
| "ext-session": "*", | ||
| "ext-xmlwriter": "*", |
There was a problem hiding this comment.
The docker setup like needs to be adapted as well.
There was a problem hiding this comment.
https://www.php.net/manual/en/xmlwriter.installation.php The XMLWriter ships with PHP and is enabled by default. It is rather cosmetic change so IDEs can consistently highlight imports.
Files Created
1.
config/sitemap.yaml- Sitemap ConfigurationThis YAML file contains:
Static routes with their paths and priorities (home, signup, about, terms, etc.)
Dynamic routes configuration with priorities for:
faq_categories(0.6) - FAQ categories from databasenewsletters(0.6) - Newsletter articles with language variants2.
src/Command/GenerateSitemapCommand.php- Console CommandA Symfony console command that:
config/sitemap.yamlstatus='Triggered',type='Normal')/newsletters/121/en/faq/1,/faq/2, etc.<loc>,<lastmod>, and<priority>elementspublic/sitemap.xmlUsage
Optional base URL override:
Example Output URLs
https://www.bewelcome.org/,/about,/signup, etc.https://www.bewelcome.org/faq/1,/faq/2,/faq/3, etc.https://www.bewelcome.org/newsletters/121/en,/newsletters/121/de, etc.Note: Testing requires PHP 8.4+ (project requirement). The command follows Symfony conventions with auto-discovery via
#[AsCommand]attribute.