Programmatically create a node with a menu link I created a node programmatically with the following code.

$data = array(
  'type' =&gt; 'inception_article',
  'title' =&gt; $msg-&gt;name,
  'body' =&gt; array(
    'value' =&gt; $msg-&gt;body,
    'format' =&gt; 'full_html'
  )
);

$node = Node::create($data);
$node-&gt;save();


I would now also like to create the menu link for the node, but I cannot figure out how to do that in Drupal 8.

How can I programmatically create a menu link for a node I create?
You can save menu link Separately using the below code on node save.

 $menu_link = MenuLinkContent::create(array(
      'title' =&gt; 'Menu Title', // Menu title is your title of menu, in this case node title
      'path' =&gt; '/path/to/node', // Menu link something like '/node/'.$nid, replace $nid with your node id
      'menu_name' =&gt; 'navigation',
      'weight' =&gt; 0,
      'bundle' =&gt; 'menu_link_content',
 ));

 $menu_link-&gt;save();