Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions docs/topics/receipt-sitemap.topic
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,40 @@
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
title="Sitemap" id="receipt-sitemap" help-id="sitemap">

<link-summary>Recipe for creating a sitemap</link-summary>
<card-summary>Recipe for creating a sitemap</card-summary>
<web-summary>Recipe for creating a sitemap</web-summary>
<link-summary>How to create a product sitemap feed</link-summary>
<card-summary>Step-by-step guide for creating a product sitemap</card-summary>
<web-summary>Step-by-step guide to creating a product sitemap feed</web-summary>

<show-structure depth="3" />

<p>
This recipe walks you through creating a product sitemap feed using Laravel Feeds. You will:
- Generate the necessary classes
- Implement the feed logic
- Expose the files via the filesystem
- Optionally reference the generated sitemap from a root sitemap.xml
</p>

<chapter title="Create files" id="create_files">
<p>
Generate the feed and its item class using the following console command:
</p>
<code-block lang="bash">
%command-make-simple% Sitemaps/Product -%command-shortcut-item%
</code-block>
</chapter>

<chapter title="Filling the feed" id="filling_the_feed">
<chapter title="Fill the feed" id="filling_the_feed">
<p>
Implement the feed root element, attributes, query builder, output filename, and item mapping as shown below:
</p>
<code-block lang="php" src="receipt-sitemap-feed.php" />
</chapter>

<chapter title="Filling the feed item" id="filling_the_feed_item">
<chapter title="Fill the feed item" id="filling_the_feed_item">
<p>
Define the XML element name and map your model properties to the corresponding sitemap tags:
</p>
<code-block lang="php" src="receipt-sitemap-feed-item.php" />
</chapter>

Expand All @@ -32,14 +49,14 @@

<chapter title="Links" id="links">
<p>
Don't forget to add a link to the folder with site maps in the
<a href="https://github.com/laravel/laravel/blob/12.x/config/filesystems.php#L76-L78">config/filesystems.php</a> configuration file:
Add a filesystem disk that points to the directory containing your sitemaps in
the <a href="https://github.com/laravel/laravel/blob/12.x/config/filesystems.php#L76-L78">config/filesystems.php</a> configuration file:
</p>

<code-block lang="php" src="receipt-sitemap-links.php" include-lines="5-" />

<p>
After that, run the console command:
Then create the public symlink so the files are accessible in the browser:
</p>

<code-block lang="bash">
Expand All @@ -51,11 +68,17 @@
<include from="snippet-generate.topic" element-id="feed_generate" />
</chapter>

<chapter title="Adding a link to the general sitemap.xml file" id="adding_a_link_to_the_general_sitemap_xml_file">
<chapter title="Add a link to the root sitemap.xml" id="adding_a_link_to_the_general_sitemap_xml_file">
<p>
If you maintain a root sitemap.xml file that references other sitemaps, add an entry like this:
</p>
<code-block lang="xml" src="receipt-sitemap-root.xml" />
</chapter>

<chapter title="Result" id="result">
<p>
A generated sitemap.xml for your products will look like this:
</p>
<code-block lang="xml" src="receipt-sitemap-feed.xml" />
</chapter>

Expand Down
5 changes: 2 additions & 3 deletions docs/topics/snippet-generate.topic
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<snippet id="feed_generate">
<p>
Now you can generate a feed using a console command:
Generate the feed by running the following console command:
</p>

<code-block lang="bash">
Expand All @@ -19,8 +19,7 @@

<snippet id="check_operation">
<p>
Check the <a href="create-feeds.topic">operation/migration</a>
file that was created for you and run the console command:
Review the generated <a href="create-feeds.topic">operation or migration</a> file, then run the appropriate console command:
</p>

<code-block lang="bash">
Expand Down